From patchwork Thu Jan 18 18:05:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 13523260 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 EA156C47422 for ; Fri, 19 Jan 2024 00:02:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71BCB6B009D; Thu, 18 Jan 2024 19:02:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6CC1E6B009F; Thu, 18 Jan 2024 19:02:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56C8D6B00A1; Thu, 18 Jan 2024 19:02:47 -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 43E2C6B009D for ; Thu, 18 Jan 2024 19:02:47 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D58EE120745 for ; Fri, 19 Jan 2024 00:02:46 +0000 (UTC) X-FDA: 81694109532.21.5EBE785 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf20.hostedemail.com (Postfix) with ESMTP id 1500D1C0017 for ; Fri, 19 Jan 2024 00:02:44 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JWxwTydv; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of shy828301@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=shy828301@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705622565; a=rsa-sha256; cv=none; b=JHYeCucvSwQy5KdKcDSmTMagUpocFn219DgHpVzP+ixWXmXRZ93QG1t6Z7rVI9WK16t+22 zlpOXiwnrECu0TxfH3RC+gv4qhFAuGEkhK1A+/NrOvUk8nk6fCzQ1G7bZNjnR0CBwZAsiI DPs8HJCE6J1OSSs14V4SLXp2STIuiI4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JWxwTydv; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of shy828301@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=shy828301@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705622565; 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=FuVI82N8U3mum68Zeo3r0N8ktAUFrixqZFP4tV0YfIY=; b=Vq8BZH+7Fq5xF2lOyPSPn4alJlS/HMC7iJKlSqchTwi9RMB0l1FHSnYVHYYnfYNvoKq8pz new4YEIC2LmikupQXzvsivHUESO7P2e4WL7vs5OK7VM0FXYhvzsZL10EZizWyTbYpyDs34 xD1D13TjM3qN6iHdbk6AfWcjV48kjGo= Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6dbb003be79so693548b3a.0 for ; Thu, 18 Jan 2024 16:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705622564; x=1706227364; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FuVI82N8U3mum68Zeo3r0N8ktAUFrixqZFP4tV0YfIY=; b=JWxwTydvUO6in0GujGbauScIo+ha53LOk8xuA5IYvDtrDW9JhSxQs8BI3LWuOXo0gG lkaDfxMQN7xaRl9CuIsbVWuEUJeqbX+4kwAeaZ0LUCQyV+KCWXqijKNewSZqWPFNZBYQ CDFrE26hz/8lsWJPQfvvCqJyPn/LrUTLXdffUK8RFVMFLxCIkTLz3Ly+nECEbHfgHZ7a 5XxSJGqLGYCa26uNStHxlxd/rSYhrAQYSd7qTJ/mWtiUHYPIylJdlmM4QrU1GG6AITbH dsioYJ7DHKFMsOjwYSFM4Qi/V2XzDn365/6mOSIATo3c6WxMRfALo6cxk2U5ScOnYpbK 4dGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705622564; x=1706227364; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FuVI82N8U3mum68Zeo3r0N8ktAUFrixqZFP4tV0YfIY=; b=JvNEU2nz0CNxJYw7t87KOYcPZAixWHHu2MFHghqFnPxVE/xQMyeHhWascXX/ZIhqqP k6kzHTkpJmr4n0ViGT5BD/+EWBfgVyJC5IT/nND6mPIScEgOOWCR6bPTIUBoipIXkFhK WfQFawArN6JKM1zGoxx2UkcMqv1kpXpairPOx9+wM1zGCXr1WkYL8Nj1Q2Gdn3wsMGqV Xbdeywe0Lrz34hW7OGjPFA2O1o+jqHbtJ+tVdUcAoOOOzKillB7L5YoRHPac0gDRj+Gh 4xg8ek27XCSIJcVWFooVLw+oEAGLw6BMJZL2NchTkr/leVvJArnsFf82zL1P90mMqBII aFNQ== X-Gm-Message-State: AOJu0YyxAHVXGjqoF2ZWtyMUUamRe1jY8dctlKiS+ZGeffciBj3lguo0 GPHJwi18P4QQmneNSuM7ggti68WsoqTrdm7JhxdTXW3zDFr9xKN4 X-Google-Smtp-Source: AGHT+IHTvP+5p5EJsvMOtO65Mw12dgFv7upmWt2R8NYaoV/i2TvLaRecMBvx+b/SXq/ew2L4vvYuQg== X-Received: by 2002:a05:6a20:6709:b0:19a:9973:2b22 with SMTP id q9-20020a056a20670900b0019a99732b22mr166093pzh.40.1705622562335; Thu, 18 Jan 2024 16:02:42 -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 a20-20020a62bd14000000b006da8f6650a2sm3833051pff.155.2024.01.18.16.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 16:02:41 -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 10:05:05 -0800 Message-Id: <20240118180505.2914778-1-shy828301@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20240118133504.2910955-1-shy828301@gmail.com> References: <20240118133504.2910955-1-shy828301@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1500D1C0017 X-Stat-Signature: ag6qkaoomrr5gpc1c9ka1tjs38hxxrxn X-HE-Tag: 1705622564-650518 X-HE-Meta: U2FsdGVkX19HL4b0lSLr+cgap7IMLczQ5JwvA/PNtL8eZJI2Z72m46CZYZKh0DFiM/tgonDOllqSNgDOnsuCngdgCrW64PLQqumeF5WPwSE5nQ+1Tfsd0WgHT/Bs8UD3VdjdL4PbcRYy7jLHE9ePacHe8RQnTzpoZOlJmCDEV+eh+LXT528uYErlFckFBa+VihadDfJbKl7TnfjPPndBrbWYXUWcDyj9ozNCfN0CNaF9rc1rW4JM4gA90JbUDWm4uUA8MGo1Sw9MRKM6Zm5S3OeamfBcesbI+BwMfrw2hASCif9Vt6/YEMbdC4Dc4qDM8PMKuun2KokHynhz1b8cLnhUy7IZIa+KJS0o+MYLxLrjK5D/xV2bqAsX/R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TlwzFjhHRzDh+spOaStljJNVNsDzqwpauuNEeGfCeMnTXoq5VLVloRpLWWjI7CvyAk3x3yXNygzk3TtkXoPVJVhc5UtojLcmRdlotWVCy5hdPGxWu9EAuuJctA+YWkODTi28xlJCXglFxf7404c1m9djwZuBX/jJM9u4FCb28G1v7HGp5SdU/11mIpLGDHc+hNBdNh4zQgCI+oys/9YvhOdF22UabHPpZDyfLUuvFFwWMbVA5g/VsndNJon9foXPYx4fldHsu81zz4Pybfjl+8UDTG70C0dF3thM2VssdToR+elWFYqpEOH3cRN97jx/Rt6o8pwgWVt+2hbdn+FJGiDaOg== 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/d0a136a0-4a31-46bc-adf4-2db109a61672@kernel.org/ [2] https://lore.kernel.org/linux-mm/CAJuCfpHXLdQy1a2B6xN2d7quTYwg2OoZseYPZTRpU0eHHKD-sQ@mail.gmail.com/ 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: Matthew Wilcox (Oracle) --- mm/huge_memory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 94ef5c02b459..66adecdc509b 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -811,6 +812,9 @@ static unsigned long __thp_get_unmapped_area(struct file *filp, loff_t off_align = round_up(off, size); unsigned long len_pad, ret; + if (IS_ENABLED(CONFIG_32BIT) || in_compat_syscall()) + return 0; + if (off_end <= off_align || (off_end - off_align) < size) return 0;