From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30F381D4154; Tue, 15 Oct 2024 12:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728994067; cv=none; b=k+IP9NSInGv8tzJPuXFtZTmsJvJUS4Pq4FUoKXvKe6OSUc5hYZl7ENPq/ks9w/+x01mGOz4BjZyqI4nJxiYK8VSbYhsYGfsQen7M5FUfdIpfwQJ4Uwe8BBBcCrnRNiv8e5cKQahi8L+d9goB8C5jmiJ8CYYma7/ZO6Ksf/ZCMao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728994067; c=relaxed/simple; bh=O7iSUKX3Uru1k16QH3yaFzFcpo9u50kJ9UUQW0rbK9A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d/piwHMpCVrBFiY8nDRwr8vkOY1H0s3Sy7AuLmaXu4QrQuk5tB9JNa/Gs9jFRr5HzoeKAI7ZQ9sVKwpjWUMhpqxGD6/0db6oy40dMkeWLVWiTRLPY3vto7gCUOTrI5oosEbLJgYPQ+LMPogAH+PD+s2ANLsDnekykTdM2wbDYxE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Mvq/Ng+o; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Mvq/Ng+o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96CC3C4CEC6; Tue, 15 Oct 2024 12:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728994067; bh=O7iSUKX3Uru1k16QH3yaFzFcpo9u50kJ9UUQW0rbK9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mvq/Ng+oKaFq+lpCGPooH/jSzOC3kG3EQ9UZ8E+eUBVeIMF4we557Aq1C+kKhIAvR Kp4c+EfNY+KUcUJ3kUcjklLRRGLNIKSCxO3zV2uBLlbjE47RHRTE5KTn0rYVPf7EW7 DF3lC6BmBltlw0q5ZHLzG7I41rR8YIPl4qUjO/fY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gerald Schaefer , Heiko Carstens , Sasha Levin Subject: [PATCH 5.15 598/691] s390/mm: Add cond_resched() to cmm_alloc/free_pages() Date: Tue, 15 Oct 2024 13:29:06 +0200 Message-ID: <20241015112504.077611510@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015112440.309539031@linuxfoundation.org> References: <20241015112440.309539031@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gerald Schaefer [ Upstream commit 131b8db78558120f58c5dc745ea9655f6b854162 ] Adding/removing large amount of pages at once to/from the CMM balloon can result in rcu_sched stalls or workqueue lockups, because of busy looping w/o cond_resched(). Prevent this by adding a cond_resched(). cmm_free_pages() holds a spin_lock while looping, so it cannot be added directly to the existing loop. Instead, introduce a wrapper function that operates on maximum 256 pages at once, and add it there. Signed-off-by: Gerald Schaefer Reviewed-by: Heiko Carstens Signed-off-by: Heiko Carstens Signed-off-by: Sasha Levin --- arch/s390/mm/cmm.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c index 1141c8d5c0d03..9b4304fa37bfc 100644 --- a/arch/s390/mm/cmm.c +++ b/arch/s390/mm/cmm.c @@ -95,11 +95,12 @@ static long cmm_alloc_pages(long nr, long *counter, (*counter)++; spin_unlock(&cmm_lock); nr--; + cond_resched(); } return nr; } -static long cmm_free_pages(long nr, long *counter, struct cmm_page_array **list) +static long __cmm_free_pages(long nr, long *counter, struct cmm_page_array **list) { struct cmm_page_array *pa; unsigned long addr; @@ -123,6 +124,21 @@ static long cmm_free_pages(long nr, long *counter, struct cmm_page_array **list) return nr; } +static long cmm_free_pages(long nr, long *counter, struct cmm_page_array **list) +{ + long inc = 0; + + while (nr) { + inc = min(256L, nr); + nr -= inc; + inc = __cmm_free_pages(inc, counter, list); + if (inc) + break; + cond_resched(); + } + return nr + inc; +} + static int cmm_oom_notify(struct notifier_block *self, unsigned long dummy, void *parm) { -- 2.43.0