From patchwork Fri Jun 21 14:42:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13707708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A29DC2BA1A for ; Fri, 21 Jun 2024 14:42:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C14AD6B0517; Fri, 21 Jun 2024 10:42:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC42C6B0518; Fri, 21 Jun 2024 10:42:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3DA16B0519; Fri, 21 Jun 2024 10:42:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 823C56B0517 for ; Fri, 21 Jun 2024 10:42:52 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2DF8A1405AE for ; Fri, 21 Jun 2024 14:42:52 +0000 (UTC) X-FDA: 82255162584.01.C3D365F Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf28.hostedemail.com (Postfix) with ESMTP id 9F78AC0015 for ; Fri, 21 Jun 2024 14:42:49 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=cbbAO5Xa; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=5oixie8v; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=DTozfRCy; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=CaGeatQv; spf=pass (imf28.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718980959; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6wnwoeCLk06XNZEIaVL4PQiNWLWxYtzsDlUjzQ3EeoM=; b=evc7oiwbaGlqyBVtfaUXaEMGFpZAzPRymkhaO6yDw5/5UJHHBWcMPwKYQwSee031Z9Zlfp M97mSCxElo3VuBig3NwAT9ZFaE7WLDzW7jQeuEmmkbc67vPaz1bShrqykalIzNIxnF+S/T QIWe14zjSygq1Td4W6qSWbkhVduVUPM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718980959; a=rsa-sha256; cv=none; b=g/0+QT3kAG0YlUmqrZnWz2qQBHCnGuu+Y6ladkRBmu+TkgbmnU/NJFL+iC4/XHWDZ1YB5K EToaUs6htRGizIA/VG7vQPdYimFGh1ejBKWVmPwuXCfceJN6NQ6ZC0O4JqjHQGUoIyTxSo PI6t2UDmnTqR2p7zBXY7jqJq4bPCxGY= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=cbbAO5Xa; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=5oixie8v; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=DTozfRCy; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=CaGeatQv; spf=pass (imf28.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CD67F1FB7C; Fri, 21 Jun 2024 14:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1718980968; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6wnwoeCLk06XNZEIaVL4PQiNWLWxYtzsDlUjzQ3EeoM=; b=cbbAO5XaEHF7u0mLA2KPA47lzCS95DbQaTsnuD8lbv2+Z94MwczJOvA87iVYip/wgDLG6o KQwaosXauIhyuxd8ohf5ltR56RCtqT6dk3m4YNdBdORoLhOExewds74cW4/oLIutqO0ikp ZXjfBbKVbw/8OS646aINCWl+TiKSSdo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1718980968; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6wnwoeCLk06XNZEIaVL4PQiNWLWxYtzsDlUjzQ3EeoM=; b=5oixie8venznp0uwV6gpQQ5paj5YUMyBzsiePRsIK+wKpGmYnszetqllwNqWCIjFuIfEVc CXm9diCewdResMAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1718980966; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6wnwoeCLk06XNZEIaVL4PQiNWLWxYtzsDlUjzQ3EeoM=; b=DTozfRCyrKgQxeTtepsCLTVG7kti/QgRiTpJAiQullAIv+Vy/AEiwtlNudq5dcXJx8Geuj JFlzIQxlM4tcNf/1PwdbadJ15Q1mBAoRl55Z5LNqXkR5shr2X0PoytgVtC6dLvEbtWi5c2 i54f80HRESrmdnQjOwNDNFLZv0TZmJU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1718980966; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6wnwoeCLk06XNZEIaVL4PQiNWLWxYtzsDlUjzQ3EeoM=; b=CaGeatQvGygW5icnQVffR8ryOXvI4gRElN8S4ShRO3ujd/K0TIDWz+oH2FX6Yb+vTJMHGp PqDP6DN5ULcDA4Bw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B26D313ACE; Fri, 21 Jun 2024 14:42:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id fJiGK2aRdWY+LgAAD6G6ig (envelope-from ); Fri, 21 Jun 2024 14:42:46 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 4A43BA05A4; Fri, 21 Jun 2024 16:42:46 +0200 (CEST) From: Jan Kara To: Andrew Morton Cc: , , Jan Kara , stable@vger.kernel.org Subject: [PATCH 1/2] Revert "mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again" Date: Fri, 21 Jun 2024 16:42:37 +0200 Message-Id: <20240621144246.11148-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240621144017.30993-1-jack@suse.cz> References: <20240621144017.30993-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1467; i=jack@suse.cz; h=from:subject; bh=2B7RZlPuQbbusvMgZX8uhs4dt/JsTyyvm7VxclEoEVQ=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmdZFdpqQS8jQrtWt2zz2j3MNHIilokZb4FhjSsLqt 3LDvNDWJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnWRXQAKCRCcnaoHP2RA2ZSgCA CjrEZqhSvAmuxHUHRlk7Pq/3CB445Z9/xxTjMDdbBopDA4vn3/5IzgCpwl7zREo+4cBHx4qNT014lY rtPaAp62RC5ECu5ZztXJDoJupSplX3KQ4WbjGMrGkfVCfZ6PnyI86iAi/XTUrof8siWiVJpcts/UMz 2K3O5rvjCv0bGnJvOS6IcpLXwr1XIS4uifkh/ufmq/+/bpjQdOzTX6iZGjAC7GNdgwCFFQFVH5wDZI c74Mk1yWNlt7OrXaVmTqz+TPAXKZMObIMwug3/AHp6rsw/wEAiWXL6bTHig4SeAaqFo8qI9vGgFvlv siwdOcqFtpJHbYhVjCWE7YTBdTIPDe X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9F78AC0015 X-Stat-Signature: dx6zy8x7anuyrpxbsewftdy8eya14bpe X-HE-Tag: 1718980969-521035 X-HE-Meta: U2FsdGVkX1+MKBNZ3EPJTIafrUHNpZ3AHuQimuEdfLZ1MPMRu18ombt+5qqYNqaT0woidzc7/AT0PX94xxfTS1xWZ+qyHXaFy8anoP9gpP7mqcQ8jmjkQfnv+U5joKkkxsAx8xlVcsbyx2747MYh08y2rUvbcE+QVvEINYDKjSPQbqxa2aCtpHn202RPpn/5iJOhNiZTd2agK1JP0GTHHaBRTYy1lQM6wAcfDYSzP9anaga34537Dyys7+SZmrHDkGTDX2oN1gyI2yDeBVfB5/Sb6o4wIbryVeU8/O7UQCA1QOSofnxit7SNKDvv9aoiKM31yvuMe3Oc8KTj4SERnUU6vgwPDmo6UOszCIPSy5UHf5Pww9FR0PsME28sI2wSzwrBeEgwmm2pQDZwf7XLnnG0IRvX3vw8fIw3qQaV25xT3IXfM9VtLDQvO34c7B+zLAUMrRa2ERFDFZ23jtxcRnaaJ5VRQuvqXvgyKdwK92xpiMje+UY8m8wdRwV7ykgZVA6P+ieq1/ghkxZ2Ctps4mMZzJuxJcOtg/r2Ki5I0jOyujBzx1tb1tYkRrhh5vYCtD0tpU6EeOzQKOOgiPgzAzICK10pAHLeVpzF5dxvcLWBd+3sIL0yjE9/VbKLKsPI7R6WGnYHLKo0V5jEl6+d7wEEIfSP82F8ig0UYtQTqhMrad8ZoGmGlpMFqokYO7rY+eRNOWDhOg7POqy5DJhg3wbmzPcd5AGvD1KMfWbGbd8FEn3q3iqluLS9zy7kzVBCybJNhW0QCmgGhL9GNyERfQtW/GkTA7EdFfEM8A6JeIScsbu9Bbe7DHA5ecKbSKzOrGOLpAEwwIJqv7CWeBh0y2731u7ou+wecd8jmHXkTxxYlXQIxOtrqMChVS4P+GhBgPA1qe96rTa4H6wZNrJVWynVpVmOl7VaDHRMx5nNtyvubgSvgy7Rw4mEwFTBFkeYPsz3TPqjfbWzjrsSGRs pmzoTi/P 99cPK5woxfyt0gjrPvt/NGN3fBWQoqv6J4xS1ox0Q61NsQIHZ6VSm4CWajfb2OxtDFdJW4Kiq2PxMicyrPDJW4umWKr6OAtbx6L8YgUxLp6zhqcLrk5j0FvnXg6kIKHRndrczc3JCFbOEUXXajkvpMWFOi57lKCWY4kPsEbhi6Yz1Gl5FPGuAJOOG2E4S4x/QKxCtaxyHDuuyCkm5iv96BI76hFhI0uR4Tvzan0xYG6EHWgMPwfjaFFwJ/XZ81QdSRE4DCN4Xy1V8wt+p/di/brMyB/HwedB4IT1UavVH6C7F5AL5AQGrhHgeF/eGm1GlRZ6M X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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. CC: stable@vger.kernel.org Fixes: 9319b647902c ("mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again") Signed-off-by: Jan Kara Reviewed-By: Zach O'Keefe --- mm/page-writeback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 12c9297ed4a7..2573e2d504af 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1660,7 +1660,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