From mboxrd@z Thu Jan 1 00:00:00 1970 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 8ED36C4828D for ; Thu, 1 Feb 2024 15:34:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDB796B006E; Thu, 1 Feb 2024 10:34:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D8B456B0075; Thu, 1 Feb 2024 10:34:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C53366B007E; Thu, 1 Feb 2024 10:34:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B617B6B006E for ; Thu, 1 Feb 2024 10:34:16 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 805DAC037A for ; Thu, 1 Feb 2024 15:34:16 +0000 (UTC) X-FDA: 81743631312.03.DA4E882 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 1ED51160024 for ; Thu, 1 Feb 2024 15:34:12 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aPEQf5Nu; spf=pass (imf08.hostedemail.com: domain of fweimer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=fweimer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706801653; a=rsa-sha256; cv=none; b=VMxFMoNbaseuSkqnv+5IcD1WHjIFTY/mtP9wouQkYcEv7wIEYjQrS63kk2BRxXaYJOl1J0 BXlVnWlJIjchNpIYUgo5RBEp7ifEpjxw45HCsm7NF6FcJ0dw/+d7bD/39Nh0cO7U/SsCeq NT9Bpd9abHDWH6oybjIalBPVvAZCeUY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aPEQf5Nu; spf=pass (imf08.hostedemail.com: domain of fweimer@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=fweimer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706801653; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PLmnE/gYkTuSx/M0LwIfDVXAISrRFGPert75rch5DJk=; b=HfNpUmwCwe+tLhMO24bvrjvnrXM7jvWnZO+g5XJRd9xSWLqJ5EvSQjpMqmGXcegmo74cOq Hlj4i5Nv0tzDrJzx5idhNRdKqBmHz9uIntGP6l9PlfzkR5AUtHPqlhputO7tZxnl2e3gZ8 gs+DRwvm+lFnIelFY+arLqH73rqFLws= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706801652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PLmnE/gYkTuSx/M0LwIfDVXAISrRFGPert75rch5DJk=; b=aPEQf5NuZmGhy166o4fNTKc24iGX7c8xKYdGLZZI9ymoR+seeYWj47WT+CGZkegt9NH2CI Qd9zQs4/zwr7xuE1LBArWOwlqUvX4bl/f09SpIEs/yzVotQIqebp1nFwwuZFgoAbv9jy3m 5Vl+V44iAZwmaailDeJE4bPVEJUubbk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-28-JXOlJ8RbOkG3YtoFU44Oiw-1; Thu, 01 Feb 2024 10:34:09 -0500 X-MC-Unique: JXOlJ8RbOkG3YtoFU44Oiw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA6E6848C0A; Thu, 1 Feb 2024 15:34:08 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B13A81C060AF; Thu, 1 Feb 2024 15:34:06 +0000 (UTC) From: Florian Weimer To: Yang Shi Cc: oliver.sang@intel.com, riel@surriel.com, fengwei.yin@intel.com, willy@infradead.org, cl@linux.com, ying.huang@intel.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 2/2] mm: mmap: map MAP_STACK to VM_NOHUGEPAGE References: <20231221065943.2803551-1-shy828301@gmail.com> <20231221065943.2803551-2-shy828301@gmail.com> <878r46ym4b.fsf@oldenburg.str.redhat.com> Date: Thu, 01 Feb 2024 16:34:01 +0100 In-Reply-To: (Yang Shi's message of "Wed, 31 Jan 2024 10:46:48 -0800") Message-ID: <87frycryfq.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1ED51160024 X-Stat-Signature: 6fmw3o6kfhkxchshtwhpqpu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LYPEykRv3ifq6/zBsQ9svheVctNX7xpPkX7WSxqXOk98KYY5ybwODVWuvNX1yMkBF0yQIW1749bgFxwn+cOOis45TK4dUuMjOE0WFpoHyQGx8hFs8m7e6bUM6ObO5PisNwfsDMgiiQnxKQFatxEmCeKkiyQ3yXzVg89CziL2YXa6NTjhRPnxhnMUZn2JFz3dIF0d/46aXJ8ZpYKErimA6adEwHDWy5WXl7xQ+ecNtoNvYRScg1YXrcwMt0ahkigbJSlNjbBvcRhdRaQ1nBFa88vLIezJZL9ycBOd3zF0tIYbwo4H3BehdHaNXNsr9aejmYWNXEFyDhKPe7gCscHACdC91lbpaiU6mL8WpeuxN9pxCgF1hH1QzdyIIEMHMBKm0OOXlO1lMnne7Yzcb/cEUcptZAYSBIxaWoWN8w== 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: * Yang Shi: > On Tue, Jan 30, 2024 at 11:53=E2=80=AFPM Florian Weimer wrote: >> >> * Yang Shi: >> >> > 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 poss= ible >> > than before. Pthread's stack area is allocated by mmap without VM_GRO= WSDOWN >> > 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. >> >> Doesn't this introduce a regression in the other direction, where >> workloads expect to use a hugepage TLB entry for the stack? > > Maybe, it is theoretically possible. But AFAICT, the real life > workloads performance usually gets hurt if THP is used for stack. > Willy has an example: > > https://lore.kernel.org/linux-mm/ZYPDwCcAjX+r+g6s@casper.infradead.org/#t > > And avoiding THP on stack is not new, VM_GROWSDOWN | VM_GROWSUP areas > have been applied before, this patch just extends this to MAP_STACK. If it's *always* beneficial then we should help it along in glibc as well. We've started to offer a tunable in response to this observation (also paper over in OpenJDK): Make thread stacks not use huge pages But this is specifically about RSS usage, and not directly about reducing TLB misses etc. Thanks, Florian