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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0956C433F5 for ; Mon, 11 Oct 2021 13:49:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 348D960C49 for ; Mon, 11 Oct 2021 13:49:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 348D960C49 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 737316B006C; Mon, 11 Oct 2021 09:49:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E6BA900002; Mon, 11 Oct 2021 09:49:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D5746B0072; Mon, 11 Oct 2021 09:49:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id 49F9B6B006C for ; Mon, 11 Oct 2021 09:49:54 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F2F4E2FDE6 for ; Mon, 11 Oct 2021 13:49:53 +0000 (UTC) X-FDA: 78684289866.06.7BCB6FF Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf06.hostedemail.com (Postfix) with ESMTP id B4260801BEC9 for ; Mon, 11 Oct 2021 13:49:53 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id na16-20020a17090b4c1000b0019f5bb661f9so53699pjb.0 for ; Mon, 11 Oct 2021 06:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=10k7yW5D+4LcaavEb5KgVuWK4194TSdRqCJ594ZSvWA=; b=axzOdcRi/yOy+p9hDMR+1+O+pZU1fCauoQ9Njk5AED31qtK4Rah8yp6fEqHDT0/itl 3TnBXFRyzrg2nq+Ssr+d1seLN7qw4Gqb6ePcAZUrfyNHUtUTKDSsvPmFBYP35f+UEYO7 qGKlbWEIN6I7yLTT9JMnBvKhyGJx1GlpeUyXUriJVedzbg2Wp73mN6JN+bs6QBqgG1nS Ue0U0YnXR3FIMcJnkfJTmyoOl0NwaG82GW7ty0WutMC42B54QYHDeS0138Brf8GPrQuE dd3l3qQ1UvQCzQok8Rkc6J/NT/3VrkZmV2/awzTSN4+xhgDNAXRk5rrDAeFHx/OZ9aoF kJwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=10k7yW5D+4LcaavEb5KgVuWK4194TSdRqCJ594ZSvWA=; b=uXb7acVKVd7SgCK+0RHFo0yXD8aakv8Kd59BjOSz+dLEjbc3EHnCY+0BVjHR3oDE62 csSl18BKd7j6+k67V8m81bLTnmKyftjp2FeDPV2bFhvo+hzlM8JeZO6oVmi1DOekIGZb +fHLDVmliM9PE5mq4zH+e18xGYXYeZX9WSDLCf3KraV88//TVYYcefuJRh1o6GJMC3PL k+PMrzFu1go9naIoaPOqve9wsXMOPzGeGyjgbkPTsAAAEi846HAv81WsOx9SnoQNPsLW C5XKl53O8HzBbeb9/dkVqiG+HBWPQ7+dWITUP3q1iwoAFFZ0ysh6rNt7n7DwVnD06brQ t3qA== X-Gm-Message-State: AOAM531w0LXoZUW8Xe5Ta1VRYjMAFDiKufhrgPF+N4qkUIcb+idQntR0 FWhSnIYYVprQHfHuDaxNkFQ= X-Google-Smtp-Source: ABdhPJz3V1dxqzffZBrfqWYqSkIM+OiMIjYd4IlGZQVCeDsPFh4svfFsLxExILNnp51bgm7brreAUg== X-Received: by 2002:a17:902:9303:b029:12c:29c:43f9 with SMTP id bc3-20020a1709029303b029012c029c43f9mr24816562plb.5.1633960192750; Mon, 11 Oct 2021 06:49:52 -0700 (PDT) Received: from kvm.asia-northeast3-a.c.our-ratio-313919.internal (24.151.64.34.bc.googleusercontent.com. [34.64.151.24]) by smtp.gmail.com with ESMTPSA id t71sm8388480pgc.29.2021.10.11.06.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Oct 2021 06:49:52 -0700 (PDT) Date: Mon, 11 Oct 2021 13:49:48 +0000 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka Cc: David Rientjes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , Pekka Enberg , Joonsoo Kim , Andrew Morton Subject: Re: Perf and Hackbench results on my machine Message-ID: <20211011134948.GA68654@kvm.asia-northeast3-a.c.our-ratio-313919.internal> References: <20211008133602.4963-1-42.hyeyoo@gmail.com> <30a76d87-e0af-3eec-d095-d87e898b31cf@google.com> <904b6e72-cc2e-2e4d-5601-dacab734bf15@suse.cz> <20211011103302.GA65713@kvm.asia-northeast3-a.c.our-ratio-313919.internal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211011103302.GA65713@kvm.asia-northeast3-a.c.our-ratio-313919.internal> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B4260801BEC9 X-Stat-Signature: ifu3bngyiaopnnwbq79yp8k5ay9p73r8 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=axzOdcRi; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-HE-Tag: 1633960193-172582 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: On Mon, Oct 11, 2021 at 10:33:02AM +0000, Hyeonggon Yoo wrote: > Hello Vlastimil. > > On Mon, Oct 11, 2021 at 09:21:01AM +0200, Vlastimil Babka wrote: > > On 10/11/21 00:49, David Rientjes wrote: > > > On Fri, 8 Oct 2021, Hyeonggon Yoo wrote: > > > > > >> It's certain that an object will be not only read, but also > > >> written after allocation. > > >> > > > > > > Why is it certain? I think perhaps what you meant to say is that if we > > > are doing any prefetching here, then access will benefit from prefetchw > > > instead of prefetch. But it's not "certain" that allocated memory will be > > > accessed at all. > > > > I think the primary reason there's a prefetch is freelist traversal. The > > cacheline we prefetch will be read during the next allocation, so if we > > expect there to be one soon, prefetch might help. > > I agree that. > > > That the freepointer is > > part of object itself and thus the cache line will be probably accessed also > > after the allocation, is secondary. > > Right. it depends on cache line size and whether first cache line of an > object is frequently accessed or not. Not first cache line because free pointer is in the middle of object or out of object area. my mistake. > >> Use prefetchw instead of prefetchw. On supported architecture > > > > If we're using prefetchw instead of prefetchw, I think the diff would be > > 0 lines changed :) > > > >> like x86, it helps to invalidate cache line when the object exists > >> in other processors' cache. > >> > >> Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> > >> --- > >> mm/slub.c | 7 +++---- > >> 1 file changed, 3 insertions(+), 4 deletions(-) > >> > >> diff --git a/mm/slub.c b/mm/slub.c > >> index 3d2025f7163b..2aca7523165e 100644 > >> --- a/mm/slub.c > >> +++ b/mm/slub.c > >> @@ -352,9 +352,9 @@ static inline void *get_freepointer(struct kmem_cache *s, void *object) > >> return freelist_dereference(s, object + s->offset); > >> } > >> > >> -static void prefetch_freepointer(const struct kmem_cache *s, void *object) > >> +static void prefetchw_freepointer(const struct kmem_cache *s, void *object) > > I wouldn't rename the function itself, unless we have both variants for > different situations (we don't). That it uses prefetchw() is internal detail > at this point. looks good. that is simpler.