Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp574048rdb; Thu, 18 Jan 2024 11:53:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/5zFkLtzUb+tSKSyPEYpZ1cQ1BcbVHES6rhXAYnetfD3z5eBCl0VCJrE5dtOSqkE9kTAU X-Received: by 2002:a9d:7a4f:0:b0:6dd:ec86:b4c3 with SMTP id z15-20020a9d7a4f000000b006ddec86b4c3mr1160659otm.65.1705607615556; Thu, 18 Jan 2024 11:53:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705607615; cv=pass; d=google.com; s=arc-20160816; b=KHHI5kSVsL4TAms+gaTGgDt/yZy0lo06Vq+TcTwVN8P50uI1kyK1jFaPml+5tFRnhH DMczRmwF02bUuEd14IX6byJOehTLYQHAnVgRxSdnr7/1Wf/PMvhT++NsyBSr3U09lxd3 8iWcGCEGMpzebYaLfYhpelrvcVnrI3aNIZRtxJQsFSyFAyGU6hgC95qBR68ZJ9BbGrAe Jmcoj+R/zTjT3QzBXt3ZPf9gNz9QKwB8+BXBMtnXnYZzBhgXtyN6N9+rML++Fdq6ss0q ZiODEvUEMZ0Tg3iSiPAIzzZr+Unmw9h7THpFMhMHJBd83c9DJSiwI71eZn+xoLmHcIN0 eZ9Q== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30526-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g3-20020ac87d03000000b0042a07b6b57fsi5245074qtb.720.2024.01.18.11.53.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 11:53:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30526-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30526-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4DFD41C21C2E for ; Thu, 18 Jan 2024 19:53:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 667DB2E632; Thu, 18 Jan 2024 19:53:29 +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 ; 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 ; 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 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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; -- 2.41.0