Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp651658rdb; Tue, 16 Jan 2024 11:23:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IExpD3GMdED0yOKx1dLxmlcoEaQnzU0TFsIcg1n0o8jJc1ClFGgUqNcOwtTnuOG1X34kPoJ X-Received: by 2002:a05:620a:4898:b0:783:4389:c03 with SMTP id ea24-20020a05620a489800b0078343890c03mr9283727qkb.0.1705432987361; Tue, 16 Jan 2024 11:23:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705432987; cv=pass; d=google.com; s=arc-20160816; b=L/AEIhdOqwzbQKSlfLqs5XfASPnBMeRoK0zwawWVzMEzW90injTQidL9fcRITmQMfa lVokbvmYJbQFlDBqcZlohbJT5cSVyPaQq5Qgfb45pnT6TmtNzJTjorBAj39wSHrTPi92 iZk0OkaF2tbPw0tneJHsNaRD8m5Q4ThKOBpmYPZvZtcFscM7cDxbZ4JG3mt8BpWBEYnW CS+eOjfiuhjGoyTWWyoAGbO7nUFo0YpAa6izY0MulcOY2j4dqT2HP/V4pGbMusT9Jn7u 0xlW48MdnkQJzyjEqnRA6nfnGZu1Os2y9zPlMV8P2zWHe5ziKht2t7Yn6oW3quS+NZ2R Q/7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=NBoJHADn5yia5WgZYpyN6Z8v9Xu4OCPM9aFDyk79ezc=; fh=L8lp2E4tV4DDVaEpnI1IoNk/qlcNyl8DBovegQw3V24=; b=nNuI9a5pw9EPYoUrSLQyk/BleTitL+HfojTxGiAISsIfoQUG3lAJNmzMxHcIzSpH4k DvSP7nClMv/1EsLsVvQZcvov6q4cbyZp842Bxx0iZGyWJa/cMO9YM9DOTYn5EP6WIAY7 yE6W/p3zz79qmJZ4ciYYBewEUY+/ZxEMJzscud2IvwbA00A3imK0lCXZjnz7cSIknLX0 eTQ20hBBF1ZV41XlMeO962kWOAKY4JpXVFfySf3FO9VnxkxIj++R4+K0QFZ7/qjjv/gE aNQd8y2/Vt+9t2N4I5IC9U2KvAyYKd4w/nd7iqjlBcRajL0v6PLhqs0w45cw9l3lwgiJ rbNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=u526PYOy; arc=pass (i=1 dkim=pass dkdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-27748-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27748-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a19-20020a05620a067300b007833d17abdcsi10254072qkh.776.2024.01.16.11.23.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 11:23:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27748-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=u526PYOy; arc=pass (i=1 dkim=pass dkdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-27748-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27748-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 0D4AE1C2385D for ; Tue, 16 Jan 2024 19:23:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 239691D525; Tue, 16 Jan 2024 19:23:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="u526PYOy" Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 CCD731CFAE for ; Tue, 16 Jan 2024 19:22:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705432979; cv=none; b=jr/ARGFj6D+mgbG7cE+8DsWUmidswLpTmkc+cVpfTMe85t/RU5bUqVC1lDIJb6hkY3zoTrge6jwlhe11UJnfJY8NaFNdO9xRew0dYnH5+FQ9bt4UBHI6jrvRaFBWDMVXqfl1yVVZr7/mxpOKwoE7UAyxWSO7gDFbX8AJiuXdAOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705432979; c=relaxed/simple; bh=zWpMJClAJpegRSjC1PPQ9eyh9UzxST5eokD55OPU79Y=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version: References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc: Content-Type:Content-Transfer-Encoding; b=D17Gn9OTaQm5kC4POpeNFkZRgwTxMHXmG9bef9lpVyrEDVXKQvj9lgBtwTkF1NmLqECnrt0ZtyMXXaA5sid4Rx0Nxv5hQvQ8nCTOdb//FjkLwGDiED+KAbo9p40CGuz1bkEHYr6lUdpL5aBwYwomANhYCaPU4XYIM9rH8eU5xoU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=u526PYOy; arc=none smtp.client-ip=209.85.208.53 Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5534180f0e9so1877a12.1 for ; Tue, 16 Jan 2024 11:22:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705432972; x=1706037772; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NBoJHADn5yia5WgZYpyN6Z8v9Xu4OCPM9aFDyk79ezc=; b=u526PYOySrch1+1U8lb2onVLN6zkebGLBHR/ylODntpgkdVjBIjGY5N46U2UMfKU7Y /npp5fHJmI/2dpLjcYBh8FvFZx3dFUHD+dxX0ofzhEbGKBPuyozTGUs2L/PgatPNfe80 35F3AMdOGSLwUoeryYcAylUSRzKAOHtJnkUnN7FKkvjcEpbl0BgRVKQlA7OJMzDSKC1l K7SIdy7qTFKSdbpa8ADETQVmCr+1PWLv9+To1KavqQK4gElyHogFajVoMgFAL9NgaoSA bYohpzqP0hYYhdUqmMSiqkz5jGh2cw8kF40po+yAzx8JK9C5YXZlhn7j9ptJWt6S0ZLu SbGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705432972; x=1706037772; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NBoJHADn5yia5WgZYpyN6Z8v9Xu4OCPM9aFDyk79ezc=; b=h7KLx1SrEDIuU7UV0tj8gOK9P9EPHk3XjyzyEqhh5d1t+MgRL3bN1VOTtEMu3lISBa 4hlahMiPEyp8DLZtUNoJsixlcynxOo20flHiqRJN8Zq+vKibIRXEB5Bx3Yobjyfzm1Kn 4ToUoArwmZ9d3GeGS6vfdDar7H5MSVdbbMsNOTfXn/Rfj3/EunpKGuq6ry6KMioeMTRt nncoTXyQ2JAnBFcoUvHyEcwu/8Uqvq+TjEFBb2y5Ql00Q3MRAQmuCkMDah+b4E/dGRZi NSi3zatRVnxAJVOvQcrkLN6IitMilPt1w4YqXsGRyMmI80iQUjyk1IC1iR9bVntZzrZl 1c2w== X-Gm-Message-State: AOJu0YxBujd82O7CiZTx4DOYtzVmMgcNz6dYxdBWJlvrddWuXYMUBPHj pkF5YMqyPWyZgmZo1nOrpnqGLODZJKYff1vQvkSN7BUQ3Jo0 X-Received: by 2002:a05:6402:2287:b0:558:8096:5c2f with SMTP id cw7-20020a056402228700b0055880965c2fmr14455edb.1.1705432971859; Tue, 16 Jan 2024 11:22:51 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231221065943.2803551-1-shy828301@gmail.com> <20231221065943.2803551-2-shy828301@gmail.com> <7433e325-9af7-4b8c-888e-07a0debf8e46@intel.com> In-Reply-To: <7433e325-9af7-4b8c-888e-07a0debf8e46@intel.com> From: "Zach O'Keefe" Date: Tue, 16 Jan 2024 11:22:14 -0800 Message-ID: Subject: Re: [PATCH 2/2] mm: mmap: map MAP_STACK to VM_NOHUGEPAGE To: Yin Fengwei Cc: Yang Shi , oliver.sang@intel.com, riel@surriel.com, willy@infradead.org, cl@linux.com, ying.huang@intel.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks Yang, Should this be marked for stable? Given how easily it is for pthreads to allocate hugepages w/o this change, it can easily cause memory bloat on larger systems and/or users with high thread counts. I don't think that will be welcomed, and seems odd that just 6.7 should suffer this. Thanks, Zach On Tue, Jan 9, 2024 at 5:36=E2=80=AFPM Yin Fengwei = wrote: > > > > On 2023/12/21 14:59, Yang Shi wrote: > > From: Yang Shi > > > > The commit efa7df3e3bb5 ("mm: align larger anonymous mappings on THP > > boundaries") incured regression for stress-ng pthread benchmark [1]. > > It is because THP get allocated to pthread's stack area much more possi= ble > > than before. Pthread's stack area is allocated by mmap without VM_GROW= SDOWN > > or VM_GROWSUP flag, so kernel can't tell whether it is a stack area or = not. > > > > The MAP_STACK flag is used to mark the stack area, but it is a no-op on > > Linux. Mapping MAP_STACK to VM_NOHUGEPAGE to prevent from allocating > > THP for such stack area. > > > > With this change the stack area looks like: > > > > fffd18e10000-fffd19610000 rw-p 00000000 00:00 0 > > Size: 8192 kB > > KernelPageSize: 4 kB > > MMUPageSize: 4 kB > > Rss: 12 kB > > Pss: 12 kB > > Pss_Dirty: 12 kB > > Shared_Clean: 0 kB > > Shared_Dirty: 0 kB > > Private_Clean: 0 kB > > Private_Dirty: 12 kB > > Referenced: 12 kB > > Anonymous: 12 kB > > KSM: 0 kB > > LazyFree: 0 kB > > AnonHugePages: 0 kB > > ShmemPmdMapped: 0 kB > > FilePmdMapped: 0 kB > > Shared_Hugetlb: 0 kB > > Private_Hugetlb: 0 kB > > Swap: 0 kB > > SwapPss: 0 kB > > Locked: 0 kB > > THPeligible: 0 > > VmFlags: rd wr mr mw me ac nh > > > > The "nh" flag is set. > > > > [1] https://lore.kernel.org/linux-mm/202312192310.56367035-oliver.sang@= intel.com/ > > > > Reported-by: kernel test robot > > Tested-by: Oliver Sang > > Cc: Yin Fengwei > > Cc: Rik van Riel > > Cc: Matthew Wilcox > > Cc: Christopher Lameter > > Cc: Huang, Ying > > Signed-off-by: Yang Shi > > Reviewed-by: Yin Fengwei > > > --- > > include/linux/mman.h | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/include/linux/mman.h b/include/linux/mman.h > > index 40d94411d492..dc7048824be8 100644 > > --- a/include/linux/mman.h > > +++ b/include/linux/mman.h > > @@ -156,6 +156,7 @@ calc_vm_flag_bits(unsigned long flags) > > return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) | > > _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) | > > _calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) | > > + _calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE) | > > arch_calc_vm_flag_bits(flags); > > } > > >