From patchwork Mon Jan 30 13:07:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13121069 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 1775EC54EED for ; Mon, 30 Jan 2023 13:07:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E5426B0072; Mon, 30 Jan 2023 08:07:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 895786B0073; Mon, 30 Jan 2023 08:07:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75CE56B0074; Mon, 30 Jan 2023 08:07:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 62BEF6B0072 for ; Mon, 30 Jan 2023 08:07:50 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3BEC1120A34 for ; Mon, 30 Jan 2023 13:07:50 +0000 (UTC) X-FDA: 80411492700.13.58BD168 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf01.hostedemail.com (Postfix) with ESMTP id 708F040023 for ; Mon, 30 Jan 2023 13:07:48 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MeM4klGK; spf=pass (imf01.hostedemail.com: domain of arnd@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=arnd@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675084068; 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:references:dkim-signature; bh=kV8SHKhbiV+TDEdIzyA1MSLd1YXW0AOlZbJnzeoTnzU=; b=kOI6ScJk2+Sh5jt+tburr8bfa6cK8Mgi4eENSoQzF2oI9ftoMWLjC7nCLJZCOY0ljkg7VH NR7AD0QACCAyCqtllPm9186l0ORVXaEmZxSzeTpadrymul+oSZ1DjK9Kh3jC5lGAZsM1Vc WOBvzWfJWtAaBcW48rvW3KD7ma3lAj0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MeM4klGK; spf=pass (imf01.hostedemail.com: domain of arnd@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=arnd@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675084068; a=rsa-sha256; cv=none; b=bJbGqY01C5pSpcdyZShmUg8s8R2M1DlVREat2feiaRkCocmFj0EmZ2xLLFQIH/ZK6t7kJz PXmKoqJCxH6ltFBKdVPKvP8YfMGxrPxPtCqlFGF4Pa2yf44oGSYIcJ4fHaVdDftPLkgbv9 lgGWMz+lhF7rPugngMicx7X3/2Qlfbk= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5D513B810A4; Mon, 30 Jan 2023 13:07:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABB31C433EF; Mon, 30 Jan 2023 13:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675084065; bh=82pzv7nUQ7xEKOT9LUE7jHsMtpD/ZVzFzf10YTQKDDM=; h=From:To:Cc:Subject:Date:From; b=MeM4klGK6M3/EzB+GGzqaj/trET6jVqY4qqcULNKq3uaclfWxZWK6C15RoifjV4kR 9t7hqvmSE296+5YIb/xkXzrljjFiwjS78ZFpBRsHruwS6WwU6lBt4t1Fed+Twq0XjB LSvAcWmYqL72kM+EibA2sgVUB8Au6Q2jlp07F+DN0a8Xlpmq315CXuGdkk0CbC36fp NYNVv7Cdu5J1FVHJC1E2nHrz5+BNp1f/QrqVVtqOmw9HHEykLtrr4HLeQn3DiUrL+X He7mo9886bCxvdCsLgb5D7ehlT1pM/obD/rRLVfkptqEKlLiHDsRnQOdj7FeVMDjUo psjK/JhIS7NzQ== From: Arnd Bergmann To: Andrew Morton , Alexander Duyck , Michal Hocko , Pavel Tatashin , Alexander Potapenko Cc: Arnd Bergmann , "Matthew Wilcox (Oracle)" , David Hildenbrand , "Liam R. Howlett" , John Hubbard , Naoya Horiguchi , Hugh Dickins , Suren Baghdasaryan , Alex Sierra , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: extend max struct page size for kmsan Date: Mon, 30 Jan 2023 14:07:26 +0100 Message-Id: <20230130130739.563628-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 708F040023 X-Stat-Signature: m15n4gp75ow9wrzeiyqjxsroahps88t4 X-HE-Tag: 1675084068-595830 X-HE-Meta: U2FsdGVkX18m+xx9gmGL2W6YhUvCC6xTMhdHWtAd47RMulOyzlLhkMp6fb7PJmg5vwwLOvLiOckVE+g6N/2Fsepr9CSb35rGdK05tq+iE9k2AlPKk4N5jgX5h5z+ka62NbzF9TtQR5EEY7c5Q0ZQ/9q4Z9OLyqgHR9gt158tviQZdY5Kq/ZEZ5xC7GlKlycx3Vwf2HVXc5D5mXvL9Ik313duGMPSzQeTFn+q2q0wMd5b+67LCJImVtrhP3D5nghqEeo7lYSnsHh6uWvMh94YeShBmZI88GWrnSE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ubZ5H7w 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: From: Arnd Bergmann After x86 has enabled support for KMSAN, it has become possible to have larger 'struct page' than was expected when commit 5470dea49f53 ("mm: use mm_zero_struct_page from SPARC on all 64b architectures") was merged: include/linux/mm.h:156:10: warning: no case matching constant switch condition '96' switch (sizeof(struct page)) { Extend the maximum accordingly. Fixes: 5470dea49f53 ("mm: use mm_zero_struct_page from SPARC on all 64b architectures") Fixes: 4ca8cc8d1bbe ("x86: kmsan: enable KMSAN builds for x86") Signed-off-by: Arnd Bergmann Acked-by: Michal Hocko Reviewed-by: Alexander Duyck Reviewed-by: Pasha Tatashin --- This seems to show up extremely rarely in randconfig builds, but enough to trigger my build machine. I saw a related discussion at [1] about raising MAX_STRUCT_PAGE_SIZE, but as I understand it, that needs to be addressed separately. [1] https://lore.kernel.org/lkml/20220701142310.2188015-11-glider@google.com/ --- include/linux/mm.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index b73ba2e5cfd2..aa39d5ddace1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -137,7 +137,7 @@ extern int mmap_rnd_compat_bits __read_mostly; * define their own version of this macro in */ #if BITS_PER_LONG == 64 -/* This function must be updated when the size of struct page grows above 80 +/* This function must be updated when the size of struct page grows above 96 * or reduces below 56. The idea that compiler optimizes out switch() * statement, and only leaves move/store instructions. Also the compiler can * combine write statements if they are both assignments and can be reordered, @@ -148,12 +148,18 @@ static inline void __mm_zero_struct_page(struct page *page) { unsigned long *_pp = (void *)page; - /* Check that struct page is either 56, 64, 72, or 80 bytes */ + /* Check that struct page is either 56, 64, 72, 80, 88 or 96 bytes */ BUILD_BUG_ON(sizeof(struct page) & 7); BUILD_BUG_ON(sizeof(struct page) < 56); - BUILD_BUG_ON(sizeof(struct page) > 80); + BUILD_BUG_ON(sizeof(struct page) > 96); switch (sizeof(struct page)) { + case 96: + _pp[11] = 0; + fallthrough; + case 88: + _pp[10] = 0; + fallthrough; case 80: _pp[9] = 0; fallthrough;