From nobody Fri Nov 29 16:28:27 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1633440890; cv=none; d=zohomail.com; s=zohoarc; b=kEhnZJDD+Yprj7eYwi1GtPFJAPc6hP//uEFOei6a/yCXsT6PjJ5vR8LrG9+hVrixFzNyyzMLeyHJLfx0EmCy876Rh+frJfwJy5onX7+5sdvJMj6sjolqwxxn2rJn6USKl6+NkTmqf5Zegy2nSA/rfVOM6QXGhqGyK800lUObNAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633440890; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=muVpN94mowz5PNDdbHLdWMwCxQCzzIFQLh6tPGkXOCw=; b=kb20fI8qox5raosC94RFB798NtuN049YLF5Caihcc5dkvle6H1PWGvo2A/y28+mtJpHDcBmN4/xdOqL/qfpyd73UgbJRow2w/4OhQPy3Gsvj66Vo46IyiH031mciH5JrzZDTJlz8tVw6W+frLb/SbN1T24inFXIiWBrxHSRVOgk= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1633440890467947.8672583280539; Tue, 5 Oct 2021 06:34:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.202273.356985 (Exim 4.92) (envelope-from ) id 1mXkac-0002zv-7W; Tue, 05 Oct 2021 13:34:38 +0000 Received: by outflank-mailman (output) from mailman id 202273.356985; Tue, 05 Oct 2021 13:34:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXkac-0002zo-4S; Tue, 05 Oct 2021 13:34:38 +0000 Received: by outflank-mailman (input) for mailman id 202273; Tue, 05 Oct 2021 13:34:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mXkab-0002ze-8J for xen-devel@lists.xenproject.org; Tue, 05 Oct 2021 13:34:37 +0000 Received: from smtp-out2.suse.de (unknown [195.135.220.29]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2b68957c-58fc-44b2-a12c-7d1a9f5ec69e; Tue, 05 Oct 2021 13:34:36 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9BBDF20028; Tue, 5 Oct 2021 13:34:35 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6487D13C35; Tue, 5 Oct 2021 13:34:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id a1xEF2tUXGHnDwAAMHmgww (envelope-from ); Tue, 05 Oct 2021 13:34:35 +0000 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: 2b68957c-58fc-44b2-a12c-7d1a9f5ec69e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1633440875; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=muVpN94mowz5PNDdbHLdWMwCxQCzzIFQLh6tPGkXOCw=; b=WB084CpVgo7IVkufWcK3GX0mN37NTIXQAwwmpfy8mfvZjcDCTnJJph90jEaoPJ8gs6E5BO s7Z+YiKqhftnBIOnEtwSjw6L/5HUFyKN3dBids+HBSzO8WlZAQPyLKQ8bJBkW6WBWRx9Qa iO4ZxJ64g3GTX589cF6hqBGZ96qyPzc= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , stable@vger.kernel.org, =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [PATCH] xen/balloon: fix cancelled balloon action Date: Tue, 5 Oct 2021 15:34:33 +0200 Message-Id: <20211005133433.32008-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1633440892288100003 In case a ballooning action is cancelled the new kernel thread handling the ballooning might end up in a busy loop. Fix that by handling the cancelled action gracefully. While at it introduce a short wait for the BP_WAIT case. Cc: stable@vger.kernel.org Fixes: 8480ed9c2bbd56 ("xen/balloon: use a kernel thread instead a workqueu= e") Reported-by: Marek Marczykowski-G=C3=B3recki Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky --- drivers/xen/balloon.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 43ebfe36ac27..3a50f097ed3e 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -491,12 +491,12 @@ static enum bp_state decrease_reservation(unsigned lo= ng nr_pages, gfp_t gfp) } =20 /* - * Stop waiting if either state is not BP_EAGAIN and ballooning action is - * needed, or if the credit has changed while state is BP_EAGAIN. + * Stop waiting if either state is BP_DONE and ballooning action is + * needed, or if the credit has changed while state is not BP_DONE. */ static bool balloon_thread_cond(enum bp_state state, long credit) { - if (state !=3D BP_EAGAIN) + if (state =3D=3D BP_DONE) credit =3D 0; =20 return current_credit() !=3D credit || kthread_should_stop(); @@ -516,10 +516,19 @@ static int balloon_thread(void *unused) =20 set_freezable(); for (;;) { - if (state =3D=3D BP_EAGAIN) - timeout =3D balloon_stats.schedule_delay * HZ; - else + switch (state) { + case BP_DONE: + case BP_ECANCELED: timeout =3D 3600 * HZ; + break; + case BP_EAGAIN: + timeout =3D balloon_stats.schedule_delay * HZ; + break; + case BP_WAIT: + timeout =3D HZ; + break; + } + credit =3D current_credit(); =20 wait_event_freezable_timeout(balloon_thread_wq, --=20 2.26.2