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 229DDC43334 for ; Mon, 27 Jun 2022 17:05:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 985B38E0002; Mon, 27 Jun 2022 13:05:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90E628E0001; Mon, 27 Jun 2022 13:05:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 788318E0002; Mon, 27 Jun 2022 13:05:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 618C68E0001 for ; Mon, 27 Jun 2022 13:05:30 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 3CC75120292 for ; Mon, 27 Jun 2022 17:05:30 +0000 (UTC) X-FDA: 79624642020.29.1F36B10 Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) by imf09.hostedemail.com (Postfix) with ESMTP id DFB63140034 for ; Mon, 27 Jun 2022 17:05:29 +0000 (UTC) Received: by mail-yb1-f171.google.com with SMTP id r3so17825244ybr.6 for ; Mon, 27 Jun 2022 10:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=llT1Zq6sh+MENUn7ZyFpz597NkMTivkH2nO9uzDfXJc=; b=hSVoyAPeZyTQ6QXLkInesPxCelw6q0JD7Hv9wsjbBHfFEdOnkZ2yvmx7AxA0Eh7LxL 5Br6FVTxPc7BCLirBQW+hf6peNUEzFOJvMNCPTWbaY6WN9blx5shC/VN1xq1zWQk2JZ1 sS/2tZbkP1G2ZnHwZpk9zwBdhJ9ydoT9I0699o4AHA7THbqNqWgs5cnENYiYAtskraqf 2kuwhXGgUbZwhBqFcRROjY03fkDh2BbMWkIszSqN8qA6NqD5lLk+ogy+J7EmL2CUFVJn nJe4Drn1fXkyqf+a9IdT7HZr+7cy2fG3pgzM+tc/VZUqb+6vNOgyaO4phFEdxPZxjP+9 brQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=llT1Zq6sh+MENUn7ZyFpz597NkMTivkH2nO9uzDfXJc=; b=tFXRPNWOdf9BoUe7I7OXaDQ9K50kzHWKHM0sF+/gS9pqFEXmourLTIYOY2baNZDlPh b6SMGCe30fYBEr9TJ3NxmCvkmZqF7vkuNdQXfvS3bCSBy/t5QiixxjLwc5uDvHzDLZ8o w09LcVXknSKLW/s5LBW3FT9JqX04VxRVJCUo23n12WmwbLcctqmLS/LM1DvgxsT/GVHk xAfT2tsG6uLwH/io06kqUDzNdghPpLgNE3NGPWc+UY+dXciURVCjEFYokmZkURga+LLE v8uWk2WoZ1FT375FAYnIdHKbBAfXwzeFKqsqWzcpJ0ILEk8liPSk4KI9IjO4RaYNwPfn 1jBg== X-Gm-Message-State: AJIora/Lw3BW51iTXpi2IrSugNeWD5NA5iM6QsGabejxKBphgZOFJOkk H9wxkyFTxSDRI1rVlL/rsMYKAB6rYuZ4tZFj8p2hfw== X-Google-Smtp-Source: AGRyM1v+tQ4QFlzlRJhm1Rkgi+oPwKgFtB3zGgIAUGtDZNUytR6VX29Z8irDx5YhFCtKUwVtXFd5otJlwfAxhslH2Mk= X-Received: by 2002:a25:d957:0:b0:66c:9476:708f with SMTP id q84-20020a25d957000000b0066c9476708fmr11488633ybg.427.1656349528655; Mon, 27 Jun 2022 10:05:28 -0700 (PDT) MIME-Version: 1.0 References: <20220623185730.25b88096@kernel.org> <20220624070656.GE79500@shbuild999.sh.intel.com> <20220624144358.lqt2ffjdry6p5u4d@google.com> <20220625023642.GA40868@shbuild999.sh.intel.com> <20220627023812.GA29314@shbuild999.sh.intel.com> <20220627123415.GA32052@shbuild999.sh.intel.com> <20220627144822.GA20878@shbuild999.sh.intel.com> In-Reply-To: From: Eric Dumazet Date: Mon, 27 Jun 2022 19:05:17 +0200 Message-ID: Subject: Re: [net] 4890b686f4: netperf.Throughput_Mbps -69.4% regression To: Shakeel Butt Cc: Feng Tang , Linux MM , Andrew Morton , Roman Gushchin , Michal Hocko , Johannes Weiner , Muchun Song , Jakub Kicinski , Xin Long , Marcelo Ricardo Leitner , kernel test robot , Soheil Hassas Yeganeh , LKML , network dev , linux-s390@vger.kernel.org, MPTCP Upstream , "linux-sctp @ vger . kernel . org" , lkp@lists.01.org, kbuild test robot , Huang Ying , Xing Zhengjun , Yin Fengwei , Ying Xu Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656349529; a=rsa-sha256; cv=none; b=nhZRep3zlg0LlagiiCwEIQ5LrQOjINVqkJrVBQhCv3PXTs9aDJKAwbPVkkAIlwnqXzWI4w gNG+yguTerwWM8iHhnB6M/C94o7NmRIHK5wmHxMemiPf0Gqw9IIATTwI8XawmDLgEfImcL VSdNZE/QxGsocjFU/ijPC/RJsipDqZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656349529; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=llT1Zq6sh+MENUn7ZyFpz597NkMTivkH2nO9uzDfXJc=; b=OvDeRp8YVGHbACm2I62KqQbY+zH1hRRmiQynrRr49rUTPq/TFbOet621OBQGG3y9lhPh60 GdJ1kSqyTE5geWG4ovhgCdC4LQjByMr36tyGHwca73F3A+V3s4Bpb30cSBn2pt4kyzC+mR 5VyB/l5+OooiXWB5/WQTcXXQWwc+57g= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=hSVoyAPe; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of edumazet@google.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=edumazet@google.com X-Stat-Signature: snm7pudkhtc6t7yxjkqapur1r4a5zj5z X-Rspamd-Queue-Id: DFB63140034 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=hSVoyAPe; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of edumazet@google.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=edumazet@google.com X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1656349529-48086 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, Jun 27, 2022 at 6:48 PM Shakeel Butt wrote: > > On Mon, Jun 27, 2022 at 9:26 AM Eric Dumazet wrote: > > > [...] > > > > > > > I simply did the following and got much better results. > > > > But I am not sure if updates to ->usage are really needed that often... > > I suspect we need to improve the per-cpu memcg stock usage here. Were > the updates mostly from uncharge path or charge path or that's > irrelevant? I wonder if the cache is always used... stock = this_cpu_ptr(&memcg_stock); if (memcg == stock->cached && stock->nr_pages >= nr_pages) { Apparently the per-cpu cache is only used for one memcg at a time ? Not sure how this would scale to hosts with dozens of memcgs. Maybe we could add some metrics to have an idea of the cache hit/miss ratio :/ > > I think doing full drain (i.e. drain_stock()) within __refill_stock() > when the local cache is larger than MEMCG_CHARGE_BATCH is not best. > Rather we should always keep at least MEMCG_CHARGE_BATCH for such > scenarios. > > > > > > > diff --git a/include/linux/page_counter.h b/include/linux/page_counter.h > > index 679591301994d316062f92b275efa2459a8349c9..e267be4ba849760117d9fd041e22c2a44658ab36 > > 100644 > > --- a/include/linux/page_counter.h > > +++ b/include/linux/page_counter.h > > @@ -3,12 +3,15 @@ > > #define _LINUX_PAGE_COUNTER_H > > > > #include > > +#include > > #include > > #include > > > > struct page_counter { > > - atomic_long_t usage; > > - unsigned long min; > > + /* contended cache line. */ > > + atomic_long_t usage ____cacheline_aligned_in_smp; > > + > > + unsigned long min ____cacheline_aligned_in_smp; > > Do we need to align 'min' too? Probably if there is a hierarchy ... propagate_protected_usage() seems to have potential high cost. > > > unsigned long low; > > unsigned long high; > > unsigned long max; > > @@ -27,12 +30,6 @@ struct page_counter { > > unsigned long watermark; > > unsigned long failcnt; > > > > - /* > > - * 'parent' is placed here to be far from 'usage' to reduce > > - * cache false sharing, as 'usage' is written mostly while > > - * parent is frequently read for cgroup's hierarchical > > - * counting nature. > > - */ > > struct page_counter *parent; > > }; > > > > > >