From nobody Sun May 19 00:17:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1703136651; cv=none; d=zohomail.com; s=zohoarc; b=MZAHP8B47lOw9IGQAaRfexFbJWNNCjS2MN+mVGrKDaXHGu57WZC8UbVrQ7Jnj+kawli0XpKszNBGqQq93/fvQ+YCsnal6ocGhj/sdj/4O9Q62Rww0LfReayTkrTPoCPxfj52UhkK3w+db/PUmMVXUfcmI7HTXcwgsG5Z4WEx2Uo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703136651; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZzObqHbWeNKxitmoVg0oGbTzko+SYVdSYHcCza/qiow=; b=Vlrfawr/oRVnFjQXGOvh/wuW8BgdHWu9G2+zX220JrAU1EFOFYBIWostyDC3WuI6WtwJe+ahdgaeRxfrx5jB0ICq8Pd3sqh+5zJchzR8vYdbA2hLvXmsDPbT74n4ket+0A2uBIA0ZPMYGyG6g85/KbQW3q0JEGPQ6PlIVgiTw7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703136651655630.390033766921; Wed, 20 Dec 2023 21:30:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658450.1027596 (Exim 4.92) (envelope-from ) id 1rGBdc-0000NZ-Me; Thu, 21 Dec 2023 05:30:28 +0000 Received: by outflank-mailman (output) from mailman id 658450.1027596; Thu, 21 Dec 2023 05:30:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGBdc-0000NS-Jx; Thu, 21 Dec 2023 05:30:28 +0000 Received: by outflank-mailman (input) for mailman id 658450; Thu, 21 Dec 2023 03:24:16 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rG9fU-0002cf-7o for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 03:24:16 +0000 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [2607:f8b0:4864:20::336]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 69f05a7b-9fb0-11ee-98eb-6d05b1d4d9a1; Thu, 21 Dec 2023 04:24:14 +0100 (CET) Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6dbb7d80df8so110494a34.1 for ; Wed, 20 Dec 2023 19:24:14 -0800 (PST) Received: from pek-lpggp6.wrs.com (unknown-105-121.windriver.com. [147.11.105.121]) by smtp.gmail.com with ESMTPSA id t26-20020a62d15a000000b006d757ef7541sm513489pfl.209.2023.12.20.19.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 19:24:12 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 69f05a7b-9fb0-11ee-98eb-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703129053; x=1703733853; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZzObqHbWeNKxitmoVg0oGbTzko+SYVdSYHcCza/qiow=; b=WS9TwwnxGOkardc9566wmrrVjlDBjx+GnzYuFA40CHDi+FjWADCPibY+P+ECGlF1F7 lAiuPQOsDFh/Vk9ZEN5K1LZ3bjhSdgEAgisfF3Tc36RphmW5BYzD6KPfHcI8DCU+JFas q19jxmhthLw65jw85oR1kPAxgPHC0JCju3QAzlfLVNj/+4Cot/yp4Y78YNs+0j5INaS1 RFVpkfxpQehllgcEacC2tJhtQSmk3TTKQeLtXBMlyXO3BdbLtdAmeoyrmOXLVL+P3oRu 7wTI7S0EijJYpHawaLIAlsG2OjgmPrUlxcL1D5onMOAflU6qL6gngrkfnzRM0OpTKLjm JOsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703129053; x=1703733853; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZzObqHbWeNKxitmoVg0oGbTzko+SYVdSYHcCza/qiow=; b=mY1kU9kCHRKdCi3oQda0LZn7gVgJQEuY18oVrRT8M/cAg7KaugOOl3LTc1ctyI1hiN u4Q10h7uD02I6U/81hx4a4W8n/85mZPBxJq+wnZnFmfLaPwwjWm3KLTxKaS1Rn1sAJj+ yv5Mur8ExP74XaRTX74OX0R0DhtgLOhr3bdsVYkg5BdykmeMCQh3gK3unJjFJYROIUqQ fjg5NktHdRz/vJQKq/GajDgoaL0CvPz5LH73vRnIRV3H5D0aD0/zQdu0fpAeqpwxkgyR Br5jtTcJWO2bctQEVhp6RA3cXeKOiZpVdAsO5OnRhWoJxW0+NfXAmReO8JXlJmTKUWK1 TBbA== X-Gm-Message-State: AOJu0Ywdo63Zr3USXbiRDSS63jXaimxUIazbuyvPoeDfx/NCBjDN8RuB 6tk13MI2IjpRj3bdjSC+8ag= X-Google-Smtp-Source: AGHT+IGqO69HbozDdaHzdkdh97/2e+jmgHJdDzIFmqXLEgdVLBzcOqGONSlcV0qLIbSY7SsabkStTg== X-Received: by 2002:a9d:7518:0:b0:6d9:ebaf:a5fa with SMTP id r24-20020a9d7518000000b006d9ebafa5famr19611013otk.54.1703129052973; Wed, 20 Dec 2023 19:24:12 -0800 (PST) From: Kevin Hao To: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Jens Axboe Cc: xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, "Rafael J. Wysocki" , Pavel Machek Subject: [PATCH] xen-blkback: Use freezable wait_event variants for freezable kthread Date: Thu, 21 Dec 2023 11:23:51 +0800 Message-Id: <20231221032351.1638686-1-haokexin@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1703136652231100001 Content-Type: text/plain; charset="utf-8" A freezable kernel thread can enter frozen state during freezing by either calling try_to_freeze() or using wait_event_freezable() and its variants. So for the following snippet of code in a kernel thread loop: try_to_freeze(); wait_event_interruptible(); We can change it to a simple wait_event_freezable() and then eliminate a function call. Signed-off-by: Kevin Hao --- drivers/block/xen-blkback/blkback.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkbac= k/blkback.c index 4defd7f387c7..bef0f950b257 100644 --- a/drivers/block/xen-blkback/blkback.c +++ b/drivers/block/xen-blkback/blkback.c @@ -563,20 +563,18 @@ int xen_blkif_schedule(void *arg) =20 set_freezable(); while (!kthread_should_stop()) { - if (try_to_freeze()) - continue; if (unlikely(vbd->size !=3D vbd_sz(vbd))) xen_vbd_resize(blkif); =20 timeout =3D msecs_to_jiffies(LRU_INTERVAL); =20 - timeout =3D wait_event_interruptible_timeout( + timeout =3D wait_event_freezable_timeout( ring->wq, ring->waiting_reqs || kthread_should_stop(), timeout); if (timeout =3D=3D 0) goto purge_gnt_list; - timeout =3D wait_event_interruptible_timeout( + timeout =3D wait_event_freezable_timeout( ring->pending_free_wq, !list_empty(&ring->pending_free) || kthread_should_stop(), @@ -593,8 +591,8 @@ int xen_blkif_schedule(void *arg) if (ret > 0) ring->waiting_reqs =3D 1; if (ret =3D=3D -EACCES) - wait_event_interruptible(ring->shutdown_wq, - kthread_should_stop()); + wait_event_freezable(ring->shutdown_wq, + kthread_should_stop()); =20 if (do_eoi && !ring->waiting_reqs) { xen_irq_lateeoi(ring->irq, eoi_flags); --=20 2.39.2