From patchwork Thu Jan 18 13:35:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 13523141 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 496FFC47DAF for ; Thu, 18 Jan 2024 19:53:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E1E46B0078; Thu, 18 Jan 2024 14:53:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 991C86B0085; Thu, 18 Jan 2024 14:53:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85A2C6B0087; Thu, 18 Jan 2024 14:53:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 73C386B0078 for ; Thu, 18 Jan 2024 14:53:28 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 044D81A0117 for ; Thu, 18 Jan 2024 19:53:27 +0000 (UTC) X-FDA: 81693481296.17.0FF8E9A Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf22.hostedemail.com (Postfix) with ESMTP id 45222C000B for ; Thu, 18 Jan 2024 19:53:26 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BnMF+mde; spf=pass (imf22.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705607606; 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=EZGu56SQkPq5onYvWGLXuBppyU+oGKlhQFwb+ijLfmY=; b=ZIg7+lKVI9h2FOsArtK67/QvXycPiTSaSoeba3oTlxKhfe43NOIBQklMC058Z12wqPazYy t5OT+J/xtXCYITjpPzIwpDGUc3S08o8XsbYmF5T4icQl4l5I9dPWfeJet9qxgu3C5g3k64 1YhrjhoUZXcs6AP4jiP8RLbdSgdkxf0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705607606; a=rsa-sha256; cv=none; b=SOjK4JAnmDhQpRSKzNjEhjHpCFF5D6k5qBDgQH9sMjEdNu/NC4w3GLvMkNSXXG5mTTJJRP uHmnJy/UQlZACo4aBCnhKxgnlktMsgehmuRY1K9O+xQDuhTjtXy898276zKvpUWpcF+I11 mNyAdohcfOiqm1qYNIgWjgu6JLAskrc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BnMF+mde; spf=pass (imf22.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2903498ae21so69483a91.1 for ; Thu, 18 Jan 2024 11:53:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705607605; x=1706212405; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EZGu56SQkPq5onYvWGLXuBppyU+oGKlhQFwb+ijLfmY=; b=BnMF+mdeKBm1RSrJ6/lfNk9buxM7BLGVQsK0SPgbw8hGJJZsf9aW/dekE70lvVbJXe 2aW10i5x5QHKMURzzqZ+F36pktP8WJNZNvVT6kkfLyhvHyZ5JIdYLJbbqIBrPH9xx6Cd D4LAyFGQHuXtP5cgVQbMNiMk77hdCpugK5l733OpHAjjzzj5Wf2R3fX6EapoOCDe0GRi usYuPzpijHNBUH6MMiiAeBl8SviBke/iigNivEs3XJPz/SaWXTcAUmi+xm936DQ+b4vB 9cRPyTT4fFk8iMvMqBpw2HgMPLtF+H4D6INjMxMZzND2OtFMPzRljuqp5n3dd8YU1qlQ BG/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705607605; x=1706212405; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EZGu56SQkPq5onYvWGLXuBppyU+oGKlhQFwb+ijLfmY=; b=n9EoXM/fzbzTcsQa5mTuC+EovnEE5qiYWSIDw5OKdgryxw69g8edkFnNDmMO5TEvDK L3WhM+TH4DqwDmlHaohNaeuD9mLzK8Lv+YdVed9PaGtIg0MDM/MoqYVM3qLInQ1ccQVt rtnC6yD/WEB2/CQ6Mn7sjQmW7L8PXzqbhxgisitthQUgTQu6yj3pHNNcc6vgiy8jHXgG 1Yp7LNTcXRb9dHyfIsrhHp3TirGX2EPg4fIvvOSuwhY1JS3OPn6veKxnlFSmdtx1/Drw 2pWR551hZe2jG6I5bl8EGKPZNa+7lkhwr7STBxExfd72c/W5awkt6VO0XO1WxofhWF9T igNQ== X-Gm-Message-State: AOJu0YxAAxsWFp42n5J9Y0zDwGswyo5TIB/P4oyraPMdBptfBeB6Icqx yvamhmVZPR246ORKfd3uPGx5DViejrCcD93bXkEACDQ640TmJmvc X-Google-Smtp-Source: AGHT+IGupQ8PU7Fa42u1C/IqqWB8MyHGZKGwJuxOH+hIX+ZSLySKufDFO7aZHyUgiK3OvCOu6aLdhw== X-Received: by 2002:a17:90b:1043:b0:28f:f82f:1881 with SMTP id gq3-20020a17090b104300b0028ff82f1881mr1085121pjb.54.1705607604959; Thu, 18 Jan 2024 11:53:24 -0800 (PST) Received: from localhost.localdomain (c-67-174-241-145.hsd1.ca.comcast.net. [67.174.241.145]) by smtp.gmail.com with ESMTPSA id nc15-20020a17090b37cf00b0028feef1f7adsm2251388pjb.50.2024.01.18.11.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 11:53:24 -0800 (PST) From: Yang Shi To: jirislaby@kernel.org, surenb@google.com, riel@surriel.com, willy@infradead.org, cl@linux.com, akpm@linux-foundation.org Cc: yang@os.amperecomputing.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: huge_memory: don't force huge page alignment on 32 bit Date: Thu, 18 Jan 2024 05:35:04 -0800 Message-Id: <20240118133504.2910955-1-shy828301@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: 45222C000B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 49r9kgykqm6zijnuqi8frxz38dz1fi9h X-HE-Tag: 1705607606-707118 X-HE-Meta: U2FsdGVkX18AeiogkCFPmA0X06Ss+znpab0Eay5hbsyAG9Q6s+5HvPT/uNYa03z9HtRzIIai8oSjtR/UGXQuwHb0VUdBWnZ6eCIPSbjmhQqmcpMiPkXOzUgzQraHIUGuxpR7LUY+QieeXwxlGn4U4cUvC/JQMbHtx39OMfi+MGG8Sln0cb/3b1BTYAr0euBtTuTRCPjkxkLTSynEYvEJbayRQ3lK5rCk7YYTO2But4vIOLwe8RjGgMY5ETcfOHbvZbHPyLxRwSCWq3dKJynQwmbpn2VG+lmTh0sK8geed7EMZaLei5t38XW+xJAA1PVvyZ0E/2aULjJHQqLyLfHRdy+Fk5j3YFbePai2h6gXyj0E0+9+atcFF8wDS0EnTb7E6BWsMxg3ddG8v9ImW3obwztF7cdLEuZZE/r+xbJqil/tIAiSOoaaFoKS7fq2mF8FVo3jld4NI22pm/Nz7wd7CEoPkmSyGgKMt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66nTGkSOWimU93Km/PWIyFkTBUQgu0vhdOA7d2TMdNsnERNH5GfuiVEfIEceDHXK7f7QgQcY1l9WAxEy+3Y6eI2/dmKxP7c04BJKR0iH4y19vJg2zYz8M0R6suEpR6RD+UYRY7/ZHVy9gpgj7IuhW9FBxzUEokKJrh9uDkH/pg24qosdz1lxi1yVvk63laH8VIv8j5lUtTjSAEBoQpyegHLcUlb6PTzhYvfkEWheBErfNs9dVDMrdtjRmvIMhFXtlyIxdngi8cWhJnionLOuGSqBxFUZPQ+/gYL9dl3 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: From: Yang Shi The commit efa7df3e3bb5 ("mm: align larger anonymous mappings on THP boundaries") caused two issues [1] [2] reported on 32 bit system or compat userspace. It doesn't make too much sense to force huge page alignment on 32 bit system due to the constrained virtual address space. [1] https://lore.kernel.org/linux-mm/CAHbLzkqa1SCBA10yjWTtA2mKCsoK5+M1BthSDL8ROvUq2XxZMw@mail.gmail.com/T/#mf211643a0427f8d6495b5b53f8132f453d60ab95 [2] https://lore.kernel.org/linux-mm/CAHbLzkqa1SCBA10yjWTtA2mKCsoK5+M1BthSDL8ROvUq2XxZMw@mail.gmail.com/T/#me93dff2ccbd9902c3e395e1c022fb454e48ecb1d Fixes: efa7df3e3bb5 ("mm: align larger anonymous mappings on THP boundaries") Reported-by: Jiri Slaby Reported-by: Suren Baghdasaryan Tested-by: Jiri Slaby Tested-by: Suren Baghdasaryan Cc: Rik van Riel Cc: Matthew Wilcox Cc: Christopher Lameter Signed-off-by: Yang Shi Reviewed-by: Rik van Riel Acked-by: Michal Hocko Tested-By: Yves-Alexis Perez --- mm/huge_memory.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 94ef5c02b459..e9fbaccbe0c0 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -811,6 +812,14 @@ static unsigned long __thp_get_unmapped_area(struct file *filp, loff_t off_align = round_up(off, size); unsigned long len_pad, ret; + /* + * It doesn't make too much sense to froce huge page alignment on + * 32 bit system or compat userspace due to the contrained virtual + * address space and address entropy. + */ + if (IS_ENABLED(CONFIG_32BIT) || in_compat_syscall()) + return 0; + if (off_end <= off_align || (off_end - off_align) < size) return 0;