Message ID | 20240118133504.2910955-1-shy828301@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-30526-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp586557dyb; Thu, 18 Jan 2024 11:53:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3lws9N+5YAEuPqr+On6A1eyS7BpG3ioy11v6wFfDp8FCGtxmTHC0VDLbrVIGEh9XDPZfa X-Received: by 2002:a05:6a00:148d:b0:6d9:b569:baba with SMTP id v13-20020a056a00148d00b006d9b569babamr1214375pfu.61.1705607623804; Thu, 18 Jan 2024 11:53:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705607623; cv=pass; d=google.com; s=arc-20160816; b=dEY2B4oIfuMCcrJ5ZxXIaVIVb9z8lOteth6IwXs3J7QqWshdVD0nfvVBGwLUfMheK/ FHp+2iY5XT6Y9+vF4yCwsV2QRSQtAW2+P+TXpZKUobvdMdA4XJqch9RzArulXBM500vb 25HGYAGFZKYws6dkJvPR2ffnZQCG+AP62QFEokuolixNi5glBBS99pjwAs79BelxrwnF Aa1ewf/JVB/R1bCs1ACRQQ72CyAt4OHqbE+dUWxGNERGZmZ9CDqZDpYHY9qPnP2oioDF KezqRiWTPgGUVNfM6ZxdG/V0G8ZS2S0qnA8/V9Rxqk+HK02Ai2eqbjACFA3If+HZbmyt 0hZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=EZGu56SQkPq5onYvWGLXuBppyU+oGKlhQFwb+ijLfmY=; fh=gCPqIBTbmjGN0Exd9KjjXqY3oenNGPLox/7Xe7O15dQ=; b=jwF0/iRbGacPP259dcDjRuBEWuXeR5Ih5NS9LVESXLpUEc+z8BT2ZYEM5gBjA4z4Nx bMnO9p8s+FrRfumOULQf1PpAAB0wzcnS5sBopiZw6Bi9LboXfxlYwEob1wi5X4RHJT/b B+weCzYR/HOtk+CQQ/Oe8njU8c87F71tozAoMiqdVVu13FSc5T7op7q22aVR20oeqvGx Agij1jF6tbKFpVfhQxb2VjkDyxzSpjuKNZYgSCCPht8kadjML94CDm6w1I+YM5oU2dhl IVA45Gn2c9W67TAFhuOvyQZvQ99/xt/ICCSZiWNe+gU3uFf97k4FBItPi8LiFMN9D+tf WRtQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=E3zBoLq8; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-30526-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30526-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q1-20020a056a00088100b006dba57e6a1asi2073078pfj.313.2024.01.18.11.53.43 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 11:53:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30526-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=E3zBoLq8; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-30526-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30526-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 81C16282FC9 for <ouuuleilei@gmail.com>; Thu, 18 Jan 2024 19:53:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3ADA92E64B; Thu, 18 Jan 2024 19:53:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E3zBoLq8" Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B427D29438 for <linux-kernel@vger.kernel.org>; Thu, 18 Jan 2024 19:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705607608; cv=none; b=Vns88hCMz4jhEzaOa3QNFN4p+v1fe4i3UBtTNt8eVlDEg/Bh9NOBZkM/JmcyPBmrCFQPmK3s0v85+3/aaT3SZYGG8ijqYSSrTR+fOHSocC8dMophodbP1vy53SMWNkmqP32COv5q0NYaA9Hj0pbuCW445SqqM2WU6yGVryrraKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705607608; c=relaxed/simple; bh=ePXeyzFZc4C49wzR3oENG78fjC6VcRFcvWg3hVa5eyI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=gG78iZ655//ntHHP9Q4J3dHPdrSha3aBfraJqLyXCM8Gxa33Y5ffpS5S3ROqcVyqNKkbK8ZMK45seI6KLjboTFtzw3dgjP41B+etJqvzLrW24EwpSX6Sq1v2quWWx/KurnkKsh93eTzTx0/1b2cdV+Cv+7V3q6ZCZvQnx/Fnpe0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E3zBoLq8; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2901ac9ba23so60697a91.3 for <linux-kernel@vger.kernel.org>; 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=vger.kernel.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=E3zBoLq85OWnbe3fb7J1MONR3TC6NDVHj4dASxvdmX8EKjEnGUDvnURqDedsUzqWQR M9h5OmtuuWiWW5CAL9+95U13AcM3UxX1EjKirntM4mBCBP0aR1hAgM2vGljMiubCbe5r bs0P2D59JBURWadp4fmkb1fsI8oK9DOgKXWpkA7B970imuj05VNsNrzjHxmcwl2UqgFT di1jx5hEQkC4H4PcYkob0LVHFZnnJsCNcnM2PeW75XP1K9pYcECY9e3K5FOKydqozNfa SI2D6H5+sVUUpxcwAfOWWX6GNHsEJrAvbKHFkAcbUpuNPmSILbKmH7VsjWDRI3/EztTl SRUQ== 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=mn7pOp252CM02tNGn7Wb4I5dg+n2a41qs18YKe9cejS2a4US6YIcdCol1QbuHasgqY Nka+Rzkdl/HjVLTidhWslZE4vr7mGBnAD9zfwgYGnbboQ/KhgfmpKzSMvz9GT/Icus4V YN5+urH3uBJmVmRnPzaWkCrp6ZHSf0sxYqt5Jd0dPcPMAITPVVGq1CsqYfgxEjpmC8Up 9WNNN13CXjqDWTwoMHxgdHCX5HJSNpWPzpIVfGcrCKoEMFyH65dziWj7UvcXPpR1WIiR yAwEh7LdkHOCqtQVNXJJeptQTqQNhan9j5RX+y76TPfMgznvyW+qJQpTLzILh6krqQJD BeWg== X-Gm-Message-State: AOJu0Yx/PoE4gnnUvhxA6GaZ7a7tCDUgEiX/GOoMNgnKySz2s3FzpW2/ lQdSZnXPN4cnRm/PJJZxYoYuGRyUWcBzRH3P/4m1n/6nubCYYtA7 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 <shy828301@gmail.com> 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788459219702802326 X-GMAIL-MSGID: 1788459219702802326 |
Series |
mm: huge_memory: don't force huge page alignment on 32 bit
|
|
Commit Message
Yang Shi
Jan. 18, 2024, 1:35 p.m. UTC
From: Yang Shi <yang@os.amperecomputing.com> 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 <jirislaby@kernel.org> Reported-by: Suren Baghdasaryan <surenb@google.com> Tested-by: Jiri Slaby <jirislaby@kernel.org> Tested-by: Suren Baghdasaryan <surenb@google.com> Cc: Rik van Riel <riel@surriel.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Christopher Lameter <cl@linux.com> Signed-off-by: Yang Shi <yang@os.amperecomputing.com> --- mm/huge_memory.c | 9 +++++++++ 1 file changed, 9 insertions(+)
Comments
On Thu, Jan 18, 2024 at 05:35:04AM -0800, Yang Shi wrote: > 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 I feel sure there are shorter URLs for those messages ... > @@ -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. > + */ I honestly wouldn't even comment this. But if you must, /* Using THP alignment is not as important as address randomisation */ > + if (IS_ENABLED(CONFIG_32BIT) || in_compat_syscall()) > + return 0; > + > if (off_end <= off_align || (off_end - off_align) < size) > return 0; > > -- > 2.41.0 >
On Thu, Jan 18, 2024 at 12:14 PM Matthew Wilcox <willy@infradead.org> wrote: > > On Thu, Jan 18, 2024 at 05:35:04AM -0800, Yang Shi wrote: > > 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 > > I feel sure there are shorter URLs for those messages ... Oh, yeah, I just found. [1] https://lore.kernel.org/linux-mm/d0a136a0-4a31-46bc-adf4-2db109a61672@kernel.org/ [2] https://lore.kernel.org/linux-mm/CAJuCfpHXLdQy1a2B6xN2d7quTYwg2OoZseYPZTRpU0eHHKD-sQ@mail.gmail.com/ > > > @@ -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. > > + */ > > I honestly wouldn't even comment this. But if you must, > > /* Using THP alignment is not as important as address randomisation */ It is not only about address randomization. Removing the comment is fine too. > > > + if (IS_ENABLED(CONFIG_32BIT) || in_compat_syscall()) > > + return 0; > > + > > if (off_end <= off_align || (off_end - off_align) < size) > > return 0; > > > > -- > > 2.41.0 > >
On Thu 18-01-24 05:35:04, Yang Shi wrote: > From: Yang Shi <yang@os.amperecomputing.com> > > 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 <jirislaby@kernel.org> > Reported-by: Suren Baghdasaryan <surenb@google.com> > Tested-by: Jiri Slaby <jirislaby@kernel.org> > Tested-by: Suren Baghdasaryan <surenb@google.com> > Cc: Rik van Riel <riel@surriel.com> > Cc: Matthew Wilcox <willy@infradead.org> > Cc: Christopher Lameter <cl@linux.com> > Signed-off-by: Yang Shi <yang@os.amperecomputing.com> Acked-by: Michal Hocko <mhocko@suse.com> Thanks! > --- > 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 <linux/page_owner.h> > #include <linux/sched/sysctl.h> > #include <linux/memory-tiers.h> > +#include <linux/compat.h> > > #include <asm/tlb.h> > #include <asm/pgalloc.h> > @@ -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; > > -- > 2.41.0 >
On Fri 26-01-24 10:41:49, Jiri Slaby wrote: > On 26. 01. 24, 10:36, Jiri Slaby wrote: > > > > --- a/mm/huge_memory.c > > > > +++ b/mm/huge_memory.c > > > > @@ -37,6 +37,7 @@ > > > > #include <linux/page_owner.h> > > > > #include <linux/sched/sysctl.h> > > > > #include <linux/memory-tiers.h> > > > > +#include <linux/compat.h> > > > > #include <asm/tlb.h> > > > > #include <asm/pgalloc.h> > > > > @@ -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. > > > > + */ > > > > FWIW, > > Bernhard noticed that "froce" and "contrained", could you fix that > > before applying the patch? > > No, you can't: > > 1) it was merged to mm-stable already, and > 2) the comment is not in that version at all [1] > > [1] https://lore.kernel.org/all/20240126075612.87780C433F1@smtp.kernel.org/ Matthew has objected that the comment is not really necessary and I think he is quite right. If anything the commend would be helpful to explain why this doesn't make much sense (because that breaks ASLR on default configuration and compat tasks). But that should be clear from the changelog so I think we are good here.
On Mon, Feb 12, 2024 at 02:45:04PM +0100, Thorsten Leemhuis wrote: > Hey Greg, is below mail still in your queue of linux-stable mails to > process? If so please apologize this interruption and just ignore this > mail. I just started to wonder if it might have fallen through the > cracks somehow, as I've seen you updating stable-queue.git for 6.7.y, > but it's still missing this patch (and the other one mentioned) -- > that's why I decided to write this quick status inquiry. Yes, my queue is quite large because of travel and the CNA/CVE work that was happening, am catching up now. I've queued these up now, thanks. greg k-h
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 <linux/page_owner.h> #include <linux/sched/sysctl.h> #include <linux/memory-tiers.h> +#include <linux/compat.h> #include <asm/tlb.h> #include <asm/pgalloc.h> @@ -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;