Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp393927rdb; Tue, 16 Jan 2024 03:53:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGWPnhyVuPiWUwI6PDMRb12ERSf/eyMoUNgrT8dUsTFAEZVa78rBBqHyowHRhfA6LXSxu/ X-Received: by 2002:a17:902:d355:b0:1d5:efdb:fcb1 with SMTP id l21-20020a170902d35500b001d5efdbfcb1mr255395plk.78.1705406002333; Tue, 16 Jan 2024 03:53:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705406002; cv=none; d=google.com; s=arc-20160816; b=fhPD25bEgt2NdGmtMqVgy9S0W+K2pghTCEr9X01K02kga3Pwzw2R63rO11QqDHJFIo s81Or1KH/jmAMII/DSsNKNV6m1/Ics6MuXks7s4l5evyyDrd7CNtzkcvOzMndDKBdMQZ TbZKIJwu9V6iOhLfa8VKUGrLAFNrzbkaUWrK94G2gEPyx1beZpuV6mlRj4sWZuQPauUq mWz4tC4XDIXkHZC3t3yt4HiD8wm8OLekslOUiedOqJmqsjo48jD6trhhwCi0WRyiY3cf 8vR5hqRaLNZX51rBczT5NqmPeR+Tk8OkR+uV8OyCyFxt3pq9NlmMSY9Y/CGBb9BhaEJt i4fQ== ARC-Message-Signature: i=1; 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=aNzCXYO/4Cv73K7mwNDUCpyL7p+nrpGfJ146LUY4hwU=; fh=KcM0W7PqrjGSrDaJLlLPw4j0CnoJDkLZRSroegSYUWM=; b=WdGpatwzkoyJ/NHLfyHSlYu3VYjU/j3/k2JGVtA6xPvK2em/Xc6wNyg1Wn0ELwIdgT 8XQSqQFqoTubWSFyLBcgOudC9Zb4BUEWh9AslpRBUpDBng0nxIApP5WSm4ZuCYDheI5k 9kdotbczGdwgO9GdDuU+dL7tXIbRgDajscfjByzMVoKMP/KjS+Sez1Ytzd+pdhJ/0Xjp TezgtWIWdOwF6Gpz1ujjuaWcffYu/u6yHFGVey5zwWhJZavd2vUoCgTmVZlbfPk/kBy+ p2E29TfHuFDh5vSlNpJ7WdUQuWYIto+KUjUXOIBr8fVAYl+rExjiXXisesiVDmIwcY/5 bYCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-27350-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27350-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. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b8-20020a170902d50800b001d44b36b701si12210535plg.512.2024.01.16.03.53.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 03:53:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27350-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-27350-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27350-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 96D6FB22737 for ; Tue, 16 Jan 2024 11:53:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FD4A1B95C; Tue, 16 Jan 2024 11:53:13 +0000 (UTC) Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 207361B94D for ; Tue, 16 Jan 2024 11:53:10 +0000 (UTC) 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-f51.google.com with SMTP id 5b1f17b1804b1-40e86c02054so1159095e9.2 for ; Tue, 16 Jan 2024 03:53:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705405989; x=1706010789; 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=DfZGs9layKIX9fwbjXHkjF4XGGcTxC9dx97HshOMXdc=; b=vjn2ScmJ4ShYGHrhu5LWybhDZzyNJrjl5HTNRlCkT4XWrZ+VKU7sarNTd189PEgufH +0HD5GQO4Q4SCBRpfqGDycIGubJcMbvLpkZSFSLXEzX3XTtlQ4cg5KZ7VuY0evljcIH6 AX0M4VsJX3lOoeDi77rQpKAYCjXSVM4emVtlTkISJab+VU3UI3jSMOFuJOtF8aPtxWDM 3p8ohCNOMOMsegCaIMVo7fk8mkbnF5+i4MkfzbrG8UZpusM+VS6OVhVleq3izrPjl6xQ SjWp55zPt2fZUdFr/ge/Z38EhBP64vonFCwSIcR4kbb6AAym4WMVWPtsL+b4hwq8rWwP Ja+A== X-Gm-Message-State: AOJu0YwBXri0UMIn/xoZXeZyzWMq+xqOpVEiZHo4wUbyzRSYS/bbdRMG LS6LCZkaTNnHDxGsrBqujygAzYbHxeRGx4He X-Received: by 2002:a05:600c:4ecc:b0:40e:500c:23d8 with SMTP id g12-20020a05600c4ecc00b0040e500c23d8mr3608197wmq.151.1705405989091; Tue, 16 Jan 2024 03:53:09 -0800 (PST) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:59? ([2a0b:e7c0:0:107::aaaa:59]) by smtp.gmail.com with ESMTPSA id p31-20020a05600c1d9f00b0040e6ea6d2d0sm3260112wms.24.2024.01.16.03.53.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jan 2024 03:53:08 -0800 (PST) Message-ID: Date: Tue, 16 Jan 2024 12:53:06 +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: Rik van Riel , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Matthew Wilcox , Yang Shi , Christoph Lameter References: <20220809142457.4751229f@imladris.surriel.com> 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 cDpcLM2LMh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99JtSIIxXxt9FJaGc1Bgsi5K/+dyTKL wLMJgiBzbVx8G+fCJJ9YtlNOPWhbKPlrQ8+AY52Aagi9WNhe6XfJdh5g6ptiOILm330mkR4g W6nEgZVyIyTq3ekOuruftWL99qpP5zi+eNrMmLRQx9iecDNgFr342R9bTDlb1TLuRb+/tJ98 f/bIWIr0cqQmqQ33FgRhrG1+Xml6UXyJ2jExmlO8JljuOGeXYh6ZkIEyzqzffzBLXZCujlYQ DFXpyMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: <20220809142457.4751229f@imladris.surriel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 09. 08. 22, 20:24, Rik van Riel wrote: > Align larger anonymous memory mappings on THP boundaries by > going through thp_get_unmapped_area if THPs are enabled for > the current process. > > With this patch, larger anonymous mappings are now THP aligned. > When a malloc library allocates a 2MB or larger arena, that > arena can now be mapped with THPs right from the start, which > can result in better TLB hit rates and execution time. This appears to break 32bit processes on x86_64 (at least). In particular, 32bit kernel or firefox builds in our build system. Reverting this on top of 6.7 makes it work again. Downstream report: https://bugzilla.suse.com/show_bug.cgi?id=1218841 So running: pahole -J --btf_gen_floats -j --lang_exclude=rust --skip_encoding_btf_inconsistent_proto --btf_gen_optimized .tmp_vmlinux.btf crashes or errors out with some random errors: [182671] STRUCT idr's field 'idr_next' offset=128 bit_size=0 type=181346 Error emitting field strace shows mmap() fails with ENOMEM right before the errors: 1223 mmap2(NULL, 5783552, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 .. 1223 <... mmap2 resumed>) = -1 ENOMEM (Cannot allocate memory) Note the .tmp_vmlinux.btf above can be arbitrary, but likely large enough. For reference, one is available at: https://decibel.fi.muni.cz/~xslaby/n/btf Any ideas? > Signed-off-by: Rik van Riel > --- > v2: avoid the chicken & egg issue with MMF_VM_HUGEPAGE (Yang Shi) > > mm/mmap.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/mmap.c b/mm/mmap.c > index c035020d0c89..1d859893436d 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -2229,6 +2229,9 @@ 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)) { > + /* Ensures that larger anonymous mappings are THP aligned. */ > + get_area = thp_get_unmapped_area; > } > > addr = get_area(file, addr, len, pgoff, flags); thanks, -- js suse labs