Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp1799993rwa; Sun, 21 Aug 2022 17:54:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR5B96EZDtUPiDB3TogGcuQJOySz3LnjAP/C6wgpZqb0/LcWxUY7P8dNljuO/VU3/xT7P8t/ X-Received: by 2002:a05:6402:27d2:b0:43e:3ff6:ad58 with SMTP id c18-20020a05640227d200b0043e3ff6ad58mr13945829ede.234.1661129672050; Sun, 21 Aug 2022 17:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661129672; cv=none; d=google.com; s=arc-20160816; b=feJwQikIHYA6Zv7e+MlLIVITEvTFPwdiOb+GU6jDCzW8fkD1wZXopIHuCVcAjTjRKv 2SaQFtZavmI+i5NspPir++XPWm+IoadLirGMDa8atcavOZPPoDXVlHQZ9luZ+oO5HUgz 2Zx6sk6fGqNqcTfMd1dJ5kv42LJqadzD5lPObw3IPXIuAUl0coJvcMRWXXJ9zxX65tc7 Zb+Y2AKeb/QuoQB1Q/gTOs1pIUPIZT0cgMvauPyIdqPsQMdHhuHyfDeBKG6D2+SPkSgg gmXN1hxZ9qm5JCl/s7jc+yoeS+Y0TSA9VnEHJZexhYpP8cACDWnhLj5rShvAnsgjl7Vq jzYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=itKnzEEgxdRanMi9GUPBS95li3Z7do6JuAGWEAWhYEg=; b=z+CbyA7h3YFfFzosOyh5NLIPA3eb7xYARO1En+TIF7IoI21dnUPw8a5uaSB2FBnF9A j5uENPfNDpWpLsOZQ8zvzjbtlsu/QppwMFS/Mz/uOXicWiap32Wc/+RAWTjsO8dxjHj+ +P9Ygpi/XXLjqA1d8PtxfMXv8yuCVMKlYzghHKcSqc7+rJy78SWx/mfut8gMUkS6OVyE KEsN9hlqvnm33c7Y70B6I5k7ynoYSferMYGFYHXzCttRkCcSLVwLs4i+2/elpQWFrwEs niyyorty1DSF2BhexW8nd55tuIIhbPqODjwmA/ANgJ6oKWgdZKLENhnADR86z9mySI5M rG/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=guVICWeq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp16-20020a1709071b1000b00730bcba7f70si8393499ejc.635.2022.08.21.17.54.06; Sun, 21 Aug 2022 17:54:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=guVICWeq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232027AbiHVAUy (ORCPT + 99 others); Sun, 21 Aug 2022 20:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232025AbiHVAUx (ORCPT ); Sun, 21 Aug 2022 20:20:53 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44E0E20185 for ; Sun, 21 Aug 2022 17:20:52 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id 2so3868585edx.2 for ; Sun, 21 Aug 2022 17:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=itKnzEEgxdRanMi9GUPBS95li3Z7do6JuAGWEAWhYEg=; b=guVICWeqFQ8c3vdR8GBUuEyOVA0+5EO5OmTjHqWEu6VFAbXZCzD8du432ghmvYgJhQ RvhjnmWNjHAres1/WFOa7u85aN+wL7vVAGauR2TkbUDtfiEBAXM8d8woD4OK3YR4i9By ROoju+R4k73Q8z6CL8yQaelkmRtkkt2ChGCPVsaia6rbwlV4wz6sduV7nkHR4czQ01aV nTYqLzKSWXx8g3YTHTp1n3tr3K0/HL5bsdRB9fZYGzYXdMycMvI6WQgC+dNqstFVupCb Dr7SNfpCd7U3oIUkjp6zD1NCoV474OmknfhA3jNoJFdCbarhzlTJZXkn6gHjiS5kG4O4 fcTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=itKnzEEgxdRanMi9GUPBS95li3Z7do6JuAGWEAWhYEg=; b=5I+SLRkQK/pQjf7oahFg53eZbBV99AtHl6U4LCu/+tg9Of3GSQEsW6MkNfGl4vjHWJ dTXzj+UOHFsDpEuFYnAtWl9oaLDXneNc7BZaH7VB68iHSlhRJGulMg2p/f8Yd3HE7uwU zFDKkrts8R/+bxoVSGibnaIISLBWVvHsNK3EfstWQAB6aEBoI73ffPZhLnqn7kLu9Q7S 21Pi+d1VyKoiu6+TsihqeaO0PJUKgVRucQewlu+S65x1SQLhngPOt4MwSXAigre8j5Js W3MUndyYhXmwfFE9UTDy0EhGhvnnMm05JXnKTGOcjIbY7FrMhbm704hh7gDYiBLcydKl N3lw== X-Gm-Message-State: ACgBeo2pMRLgWno4kpVw6NAHhcEF6JDwUoLDZ6h8IAM3EjqDOoZmjeEv 77EBStQDqkZ+CiNYoNqZVzUTycrzOmGdAt3UUY3PwQ== X-Received: by 2002:a05:6402:5ca:b0:43b:6e01:482c with SMTP id n10-20020a05640205ca00b0043b6e01482cmr14637867edx.189.1661127650293; Sun, 21 Aug 2022 17:20:50 -0700 (PDT) MIME-Version: 1.0 References: <20220822001737.4120417-1-shakeelb@google.com> <20220822001737.4120417-2-shakeelb@google.com> In-Reply-To: <20220822001737.4120417-2-shakeelb@google.com> From: Soheil Hassas Yeganeh Date: Sun, 21 Aug 2022 20:20:14 -0400 Message-ID: Subject: Re: [PATCH 1/3] mm: page_counter: remove unneeded atomic ops for low/min To: Shakeel Butt Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Eric Dumazet , Feng Tang , Oliver Sang , Andrew Morton , lkp@lists.01.org, cgroups@vger.kernel.org, linux-mm , netdev , linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 21, 2022 at 8:17 PM Shakeel Butt wrote: > > For cgroups using low or min protections, the function > propagate_protected_usage() was doing an atomic xchg() operation > irrespectively. It only needs to do that operation if the new value of > protection is different from older one. This patch does that. > > To evaluate the impact of this optimization, on a 72 CPUs machine, we > ran the following workload in a three level of cgroup hierarchy with top > level having min and low setup appropriately. More specifically > memory.min equal to size of netperf binary and memory.low double of > that. > > $ netserver -6 > # 36 instances of netperf with following params > $ netperf -6 -H ::1 -l 60 -t TCP_SENDFILE -- -m 10K > > Results (average throughput of netperf): > Without (6.0-rc1) 10482.7 Mbps > With patch 14542.5 Mbps (38.7% improvement) > > With the patch, the throughput improved by 38.7% > > Signed-off-by: Shakeel Butt > Reported-by: kernel test robot Nice speed up! Acked-by: Soheil Hassas Yeganeh > --- > mm/page_counter.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/mm/page_counter.c b/mm/page_counter.c > index eb156ff5d603..47711aa28161 100644 > --- a/mm/page_counter.c > +++ b/mm/page_counter.c > @@ -17,24 +17,23 @@ static void propagate_protected_usage(struct page_counter *c, > unsigned long usage) > { > unsigned long protected, old_protected; > - unsigned long low, min; > long delta; > > if (!c->parent) > return; > > - min = READ_ONCE(c->min); > - if (min || atomic_long_read(&c->min_usage)) { > - protected = min(usage, min); > + protected = min(usage, READ_ONCE(c->min)); > + old_protected = atomic_long_read(&c->min_usage); > + if (protected != old_protected) { > old_protected = atomic_long_xchg(&c->min_usage, protected); > delta = protected - old_protected; > if (delta) > atomic_long_add(delta, &c->parent->children_min_usage); > } > > - low = READ_ONCE(c->low); > - if (low || atomic_long_read(&c->low_usage)) { > - protected = min(usage, low); > + protected = min(usage, READ_ONCE(c->low)); > + old_protected = atomic_long_read(&c->low_usage); > + if (protected != old_protected) { > old_protected = atomic_long_xchg(&c->low_usage, protected); > delta = protected - old_protected; > if (delta) > -- > 2.37.1.595.g718a3a8f04-goog >