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 6419AC28D13 for ; Mon, 22 Aug 2022 14:57:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 390358D0002; Mon, 22 Aug 2022 10:57:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33E6F6B0075; Mon, 22 Aug 2022 10:57:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2550D8D0002; Mon, 22 Aug 2022 10:57:36 -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 16F6E6B0074 for ; Mon, 22 Aug 2022 10:57:36 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CFEB981244 for ; Mon, 22 Aug 2022 14:57:35 +0000 (UTC) X-FDA: 79827532470.07.1F7FBF1 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf15.hostedemail.com (Postfix) with ESMTP id F1021A00EC for ; Mon, 22 Aug 2022 14:56:10 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id g18so11277818pju.0 for ; Mon, 22 Aug 2022 07:56:10 -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=Q7WYgfj+D74q3tCpU5JrwR7f8DS8YPdEHB5QL4Zw+3E=; b=jjZM2OFr/3FVWHbl+N6HxUndM4ZQsTxjvR0U5CsuexneKgVxqdV1bXLtaFMj4Z0OGG 3rbrlz78/uOXN4/dBpeueMFz7QDTr89EvKklVfCjuU38Xe6odVZy5ZIZfFogK2w9Kz08 O2Xg6uOeH2cAeEZ7kHIG3YkhVp1G7ltowW0IQOo8qvWCACurSPdYzcOV5ebirHsqU4fv BrKhmOCSgPClIiIzFGj5oOJ2erOyckssP0wY1islBfgBntr7B/hpZWVE5+nTof6D/jks FYtLJt7EkaEUp/kmK6o9V8yjRSu6idnj6Btq68OCK3Qjp59HUWfIapwm0yH6RRbPlx4F UBMA== 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=Q7WYgfj+D74q3tCpU5JrwR7f8DS8YPdEHB5QL4Zw+3E=; b=k3R3TQTqNqemF5Cjk+Yc3fIAF5Fqmd73sdXhTTi6KNpHGnBxWVf46oDZI5xiRBRv6x uBvlIPdlG1IIYGiZuN23hi0zxPXW9M5Nhheb2Mr5k59YC15nx444pXUfVXDtOCv7i1c8 oefaNgpJwrM1znUboAKqwFByTs/KFWW6aNQ7hNGIelo+X13RzJQ0/NFCSGwibdGdpGpS y210dZ5w/OQKDSE4OsFc3bXU612aPBBcBqInuhWbbHaiSSdNOrBgeFISXMccxKN2YpK8 +lobtlxnwB3xRKR1taKBZNG6LC3Wk/L2//ZRJjizLTA9Zt0QpRMAtlZMWyP/4MuSGrM/ xyOA== X-Gm-Message-State: ACgBeo1u8BLuIJQ3Z6qHm2pdVCNFpI9xu1UrADq5JBDpqooE9unD9/Pq PANHNuWJQSz4o9AiyureTA08udt/EaEwumIpEVjm9g== X-Google-Smtp-Source: AA6agR4pjeCo4sfTRvPxIMsKbhBf7tq6lkeLni7LueWtlNFZuZBasGE1lD6mN+eHQeRHv7PGybIw63IFG+r7joXQ1gM= X-Received: by 2002:a17:90b:4d0f:b0:1f7:ae99:b39d with SMTP id mw15-20020a17090b4d0f00b001f7ae99b39dmr23665783pjb.237.1661180169772; Mon, 22 Aug 2022 07:56:09 -0700 (PDT) MIME-Version: 1.0 References: <20220822001737.4120417-1-shakeelb@google.com> <20220822001737.4120417-2-shakeelb@google.com> In-Reply-To: From: Shakeel Butt Date: Mon, 22 Aug 2022 07:55:58 -0700 Message-ID: Subject: Re: [PATCH 1/3] mm: page_counter: remove unneeded atomic ops for low/min To: Michal Hocko Cc: Johannes Weiner , Roman Gushchin , Muchun Song , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Eric Dumazet , Soheil Hassas Yeganeh , Feng Tang , Oliver Sang , Andrew Morton , lkp@lists.01.org, Cgroups , Linux MM , netdev , LKML Content-Type: text/plain; charset="UTF-8" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661180170; 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=Q7WYgfj+D74q3tCpU5JrwR7f8DS8YPdEHB5QL4Zw+3E=; b=uR0nqeMk5WcRK3SO6DSKze+c/aL0ddgdHHaYEa0eH3bAOs2w7LLuAVfLy28aBEkb4xdJMT nxKqlYJXRCu0Vo95+CSdN+MwgW8zqr+lIX5o2hZBRjyFBD4FqpcqTN/nTOpgA59fcPmj7V 7qe+4ptNI2VQZXP5gjGYqUKoZE+vhNE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=jjZM2OFr; spf=pass (imf15.hostedemail.com: domain of shakeelb@google.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=shakeelb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661180170; a=rsa-sha256; cv=none; b=dIYL4gsRsQdfF3JQ7qtu6yVYXGtcnYM85zTE8E9khJdETEOKvDC6iM88cwehJ8dCHuj1GC 9HvuAewVj+etSAJqsgWc7Rq2MGLkm/JCJMY0nuGtRDNuIPtX4/fDiKkWrEeOLVKdGNdXAt l79a6HG7UtlYhPscnTuRNnEOeXeqv58= X-Stat-Signature: hmchossbiwbwaanoi34posiczrgi14jf Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=jjZM2OFr; spf=pass (imf15.hostedemail.com: domain of shakeelb@google.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=shakeelb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: F1021A00EC X-Rspam-User: X-HE-Tag: 1661180170-567253 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, Aug 22, 2022 at 3:18 AM Michal Hocko wrote: > > On Mon 22-08-22 11:55:33, Michal Hocko wrote: > > On Mon 22-08-22 00:17:35, Shakeel Butt wrote: > [...] > > > 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) { > > > > I have to cache that code back into brain. It is really subtle thing and > > it is not really obvious why this is still correct. I will think about > > that some more but the changelog could help with that a lot. > > OK, so the this patch will be most useful when the min > 0 && min < > usage because then the protection doesn't really change since the last > call. In other words when the usage grows above the protection and your > workload benefits from this change because that happens a lot as only a > part of the workload is protected. Correct? Yes, that is correct. I hope the experiment setup is clear now. > > Unless I have missed anything this shouldn't break the correctness but I > still have to think about the proportional distribution of the > protection because that adds to the complexity here. The patch is not changing any semantics. It is just removing an unnecessary atomic xchg() for a specific scenario (min > 0 && min < usage). I don't think there will be any change related to proportional distribution of the protection.