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 5E0C9194C65 for ; Tue, 30 Jul 2024 09:24:56 +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=1722331496; cv=none; b=BxV9uEwDu0KnSLIHJ/xZUwSjtDIjgtKmdt6R3YOU5fEfh/q+S4uopE9Ho7jp2bpjwSrpbLJqx5ubRq8bYTYIsx8Zxkls6LaHAeTeC1h243CWIwJwmenvAaXCpG14nFSydJZdXEixSIy1lCLHR3vrqo4tBycDRExFeo+J68R5C9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722331496; c=relaxed/simple; bh=yrhTpEe5TRWLAaDzZHsZmyk8U4nZ2FCluwJd1mXg/j4=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=nxWjjqGT79DnYIAZDl8iejtadIZro0N4QZO00l91I3BKNeMYgbYAcWYm2W7kl0+RVBj3WFEkvxT2Uhogq4YytK1PSGot/orHaGKi638JCl/YfK8Z39mhkWpmdrGiSG9MaHdbx1ouqxg0wZiXaN4FgtwItsOrRu6MFOsuc4nd/yk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gVMwBYb6; 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="gVMwBYb6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64597C32782; Tue, 30 Jul 2024 09:24:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722331495; bh=yrhTpEe5TRWLAaDzZHsZmyk8U4nZ2FCluwJd1mXg/j4=; h=Subject:To:Cc:From:Date:From; b=gVMwBYb6wl6SmMl/tjQfQIerKd58KDjqkRYBulF7S7PXx90PCAzcrdvEGgciF2I7+ TJJMApoSxE6dA01QLE6AYRBN7/Ngkxgn/++AXFBFyfozD5EYph3TGb/OlXwHyib60e bF/sWjeTZmAKYav1AsX32+lstPe+u8mSBexOqdX0= Subject: FAILED: patch "[PATCH] Revert "mm/writeback: fix possible divide-by-zero in" failed to apply to 4.19-stable tree To: jack@suse.cz,akpm@linux-foundation.org,stable@vger.kernel.org,zokeefe@google.com Cc: From: Date: Tue, 30 Jul 2024 11:24:36 +0200 Message-ID: <2024073036-headed-ethically-758e@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 4.19-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.19.y git checkout FETCH_HEAD git cherry-pick -x 8dfcffa37094fef2c8cf8b602316766a86956d07 # git commit -s git send-email --to '' --in-reply-to '2024073036-headed-ethically-758e@gregkh' --subject-prefix 'PATCH 4.19.y' HEAD^.. Possible dependencies: 8dfcffa37094 ("Revert "mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again"") 9319b647902c ("mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 8dfcffa37094fef2c8cf8b602316766a86956d07 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Fri, 21 Jun 2024 16:42:37 +0200 Subject: [PATCH] Revert "mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again" Patch series "mm: Avoid possible overflows in dirty throttling". Dirty throttling logic assumes dirty limits in page units fit into 32-bits. This patch series makes sure this is true (see patch 2/2 for more details). This patch (of 2): This reverts commit 9319b647902cbd5cc884ac08a8a6d54ce111fc78. The commit is broken in several ways. Firstly, the removed (u64) cast from the multiplication will introduce a multiplication overflow on 32-bit archs if wb_thresh * bg_thresh >= 1<<32 (which is actually common - the default settings with 4GB of RAM will trigger this). Secondly, the div64_u64() is unnecessarily expensive on 32-bit archs. We have div64_ul() in case we want to be safe & cheap. Thirdly, if dirty thresholds are larger than 1<<32 pages, then dirty balancing is going to blow up in many other spectacular ways anyway so trying to fix one possible overflow is just moot. Link: https://lkml.kernel.org/r/20240621144017.30993-1-jack@suse.cz Link: https://lkml.kernel.org/r/20240621144246.11148-1-jack@suse.cz Fixes: 9319b647902c ("mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again") Signed-off-by: Jan Kara Reviewed-By: Zach O'Keefe Cc: Signed-off-by: Andrew Morton diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7168e25f88e5..c4aa6e84c20a 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1683,7 +1683,7 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc) */ dtc->wb_thresh = __wb_calc_thresh(dtc, dtc->thresh); dtc->wb_bg_thresh = dtc->thresh ? - div64_u64(dtc->wb_thresh * dtc->bg_thresh, dtc->thresh) : 0; + div_u64((u64)dtc->wb_thresh * dtc->bg_thresh, dtc->thresh) : 0; /* * In order to avoid the stacked BDI deadlock we need