Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp171952rdb; Wed, 17 Jan 2024 23:06:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvC9AR9VOn2POVr+P+3mRixmAd663mazBuTQoElQr3I4K0rSfBiOEBL/gQNFHMzwTAs7XJ X-Received: by 2002:a05:6a20:d903:b0:19a:57e9:c7af with SMTP id jd3-20020a056a20d90300b0019a57e9c7afmr3053797pzb.20.1705561584032; Wed, 17 Jan 2024 23:06:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705561584; cv=pass; d=google.com; s=arc-20160816; b=QWQR/yKFZWFw7kygcYDa4QB6kJ6SW4MHKAGTzJ8jdD6ynv52E7fdU2mMZAtecEGtW9 dl4P98WvPXy5wwM2VtbkyykNlX5nQL+GdMhcqGEmUjXtFrws6Bn1SfKoiKO7K1e8Wjlp xetxaSWHOsZNHFYyW0plHPx36pbNYkH1bsykBnAaO8nPQKMeV6il9vk4C6I/xx+XOzci Tq8PxrjzP9KKe63rev9X/4YTRdB67HbXJHpXn4b44/CkBMhL3X3I324xVYeUjs5FL9KZ iesfn6RmVwAUFaUhJnWa1qIycvgd0keaP67f5zCMaBHWsQKbzrrs9BOLhJZ+8n7/0g9Z /n6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=5S4lXTmw9h953xURv594T5Yo3rY/dm6ydiBKsQ3CdKQ=; fh=2uOBRJPQULdsbhbTuRW6R4gEnffz4AvsACfUvsGJSn8=; b=Df7D4fBtw7fxzDSINFD2vOQCRI94GhrvzxJ9XOu9irnjD/yWIUT9y8ITF6Zw3y0+2k kMxTPforWOtbOEgz7lJJVxxYmOa8l6oR7y66tEW+mudpM0kgJL90K0nyfpbS8NndAV37 T/a8VyHHZfDpIR3CmbqbuKx1k22Jp5xpjaXU6JJfmB89Nf3ARKmQETAGz0BZ4eiL48pc muCsqpxcTBveKEHjNlGhgXNz8mZpgVsTMtCXVNMr72ijxRskcfnFB93Q7kg3q0P26iLJ b2axhXvdXOgy85ADN1PmYFEmAH8uwBPY+PtRT7rx5TmkNEhaHSretDVte+QZGI9AFKZ3 7/jA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-29751-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29751-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h22-20020a632116000000b005ce176ad6besi956044pgh.280.2024.01.17.23.06.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 23:06:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29751-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-29751-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29751-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 26964B21E99 for ; Thu, 18 Jan 2024 07:05:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35A109475; Thu, 18 Jan 2024 07:05:02 +0000 (UTC) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 1C16A9444 for ; Thu, 18 Jan 2024 07:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705561501; cv=none; b=dJ1jtNCWnao6W4/Qa19ySo9ZDtzkC+u+pKxrb1GnN7Yw/oqvkwPVrLpSFhcYkY23sqavjRdBdONNmU2XuCfmw9/jhd3JEnyY5ly0r0COejstQh7lC6rmCnN7QLYnjEkadg8+2WphOY8cV8Nq9p6RbeVe3YAYILqdLhv40r9mebo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705561501; c=relaxed/simple; bh=v0d+o+oyU2L+qDUyAPW9p8OAzcs2j9iv1LOXtPMvlvU=; h=Received:X-Google-DKIM-Signature:X-Gm-Message-State: X-Google-Smtp-Source:X-Received:Received:Message-ID:Date: MIME-Version:User-Agent:Subject:Content-Language:To:Cc:References: From:Autocrypt:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=f+0urOR4LjdBo4o6ca/YhZzG49UZIB6Jp2u3D12eU74zlL56v6IEEvck8scQHAF2QKDjtOvjSAM0gvVjeJUZKCnDEAiF9Qw+wg0QQdN7F3aTgfNKhjB1U3MaG+xyCTDJWoX/ZX+oLPlOwMGj7DcoMGTNpqkfXbhMFhX2blWcRoA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-40e60e137aaso69936685e9.0 for ; Wed, 17 Jan 2024 23:04:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705561498; x=1706166298; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5S4lXTmw9h953xURv594T5Yo3rY/dm6ydiBKsQ3CdKQ=; b=K3BfpAgSFK9/drbAQtqSHbQgnaas9std7bomLsspHP4EAXBMefbXe5z6GfftSd1Ld3 e37K0kGBRsCRh114PQw0H+n+fl4YgWrJ6nRs+IV4o+ngldA1kDeFMr+8DMSEQCXtHNtM gZxelVT7OJSvv5c7mZaWQfbhXbw5ILmldS+b9fccaPMgvJf3Hb4zL93QgmNNhJti3tM+ j/pskFy90M1K65gWGyqpDKnRb/liF0tLVywGpvejvB0wyvGw7pNcMTJ0gzA51fNeyTly jxeRUlnxW/UlmhwXVQ2n89Jrnf6aE0sEl0brkczAbHFxd9ihOR2fhHOqWrVIYzcwhTNn e6qA== X-Gm-Message-State: AOJu0YzYARzyqCNsWf+s+2DJi+UKyGNGecWonlpRjY04USlkRczG75HU vBbuWC/zA3rRYv4QBRArjKOrlib/bm3AgIX43CBtUV7BWI7hlSd7 X-Received: by 2002:a05:600c:4513:b0:40e:4119:cb4a with SMTP id t19-20020a05600c451300b0040e4119cb4amr236147wmo.15.1705561498062; Wed, 17 Jan 2024 23:04:58 -0800 (PST) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:59? ([2a0b:e7c0:0:107::aaaa:59]) by smtp.gmail.com with ESMTPSA id h6-20020a05600c350600b0040c6d559490sm24785527wmq.3.2024.01.17.23.04.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Jan 2024 23:04:57 -0800 (PST) Message-ID: <7103dfea-0db3-44b7-9b2e-e89d4edd19d7@kernel.org> Date: Thu, 18 Jan 2024 08:04:56 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mm: align larger anonymous mappings on THP boundaries Content-Language: en-US To: Yang Shi Cc: Rik van Riel , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Matthew Wilcox , Christoph Lameter References: <20220809142457.4751229f@imladris.surriel.com> <3193bf5b-4e22-412f-8c5b-68574942d9bc@kernel.org> From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcDwGs6tFVrAHvdHeIdI07s1iIx5R/ndcHwt4fvI8CL5PzPmn5J+h0WERR5rFprRh6axhOk rSD5CwQl19fm4AJCS6A9GJtOoiLpWn2/IbogPc71jQVrupZYYx51rAaHZ0D2KYK/uhfc6neJ i0WqPlbtIlIrpvWxckucNu6ZwXjFY0f3qIRg3Vqh5QxPkojGsq9tXVFVLEkSVz6FoqCHrUTx wr+aw6qqQVgvT/McQtsI0S66uIkQjzPUrgAEtWUv76rM4ekqL9stHyvTGw0Fjsualwb0Gwdx ReTZzMgheAyoy/umIOKrSEpWouVoBt5FFSZUyjuDdlPPYyPav+hpI6ggmCTld3u2hyiHji2H cDpcLM2LMhlHBipu80s9anNeZhCANDhbC5E+NZmuwgzHBcan8WC7xsPXPaiZSIm7TKaVoOcL 9tE5aN3jQmIlrT7ZUX52Ff/hSdx/JKDP3YMNtt4B0cH6ejIjtqTd+Ge8sSttsnNM0CQUkXps w98jwz+Lxw/bKMr3NSnnFpUZaxwji3BC9vYyxKMAwNelBCHEgS/OAa3EJoT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hrG1+Xml6UXyJ2jExmlO8JljuOGeXYh6ZkIEyzqzffzBLXZCujlYQ DFXpyMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 18. 01. 24, 1:07, Yang Shi wrote: >> This works around the problem, of course (but is a band-aid, not a fix): >> >> --- a/mm/mmap.c >> +++ b/mm/mmap.c >> @@ -1829,7 +1829,7 @@ get_unmapped_area(struct file *file, unsigned long >> addr, unsigned long len, >> */ >> pgoff = 0; >> get_area = shmem_get_unmapped_area; >> - } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) { >> + } else if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && >> !in_32bit_syscall()) { >> /* Ensures that larger anonymous mappings are THP >> aligned. */ >> get_area = thp_get_unmapped_area; >> } >> >> >> thp_get_unmapped_area() does not take care of the legacy stuff... > > Could you please help test the below patch? It is compiled, but I > don't have 32 bit userspace or machine to test it. Yeah, for x86_64, it's semantically the same as the above, so this works too: Tested-by: Jiri Slaby > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -811,6 +811,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; thanks, -- js suse labs