Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1207101rwb; Wed, 26 Jul 2023 09:03:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlHy03Lmw5l8SSv5oKXmE5IcN4DZaA8XceT6q8DzWSuFlxqsCjCZb1uEo8pE31pvPnOtZ0gh X-Received: by 2002:a17:902:db05:b0:1b5:4679:568f with SMTP id m5-20020a170902db0500b001b54679568fmr2438914plx.45.1690387394396; Wed, 26 Jul 2023 09:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690387394; cv=none; d=google.com; s=arc-20160816; b=oTqE79v4zxQyGfKedqGHGu84JMKWymovhRjqoFzQRvYvSRgCDSB4LLqQtnVj7ocYpO ztBDtfpge010eNsuSObu71t+cyIufn3hY5dorwuDseU7YvTpX8Qp+MbHzsuGnNy/OLAK 8iNjgnBOHxbHnIr0zvdQlQp6GnG1gfxaXDHVkhUo1PXS4XHD88hBhi5hQDbo4yT6N6mX 7WIGxMPH8tfg8Kyhp7rlxAFhdCnhZqsh9TtQVxuUy01KK8mz1e+5uMGPWAQ54GXIqpTw QMbJ1Ro7rAhavA1CbRlbrTXomeRIV9Sow1wtYhyUoGR9RMHdEwSREVoE6Sz/VeCfxfSv c1uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=EmHtEDaViE9w7v3YPcqZQ4Gg5qZi74veSidbXAx7Uuk=; fh=0YAfyguERTN6Y89q2SnWxMXGGJ1lpFIbQwm60KRztPs=; b=Dx6UqSMXMLQ5ALwtAzqOgPKQlmc+NMyoT6V4VdYCLQTWOYSA/kMraWa5bVPeAPqMjo /8JsInsYovt8if2AQLjKMIlPlnKyotew3zOiUX/rLaLG39bS/fYcRrv3JzTUsWzqiML+ L3WHlzl9jIsjoEMlGBdmPFB3myQkYaixW5uidvejmGj4gozZKJJ1OWUU7pMC5Fxu4UrM CgHThZFQ6/ST3CCJnt9JPuDCF9WIYHLo6kjC2Z6SBNukWk2rpRWXKmpDK55SHlPVAAAk MBQMyUxCBeHJ1xFrjtBaBki9ioDaELQZACIqQ2n5ZDftrhr/gRezY89nBy3UyOUx1eru xNtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="Z0sm/6Yl"; 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 im23-20020a170902bb1700b001bb7b0a67cfsi9713979plb.31.2023.07.26.09.02.44; Wed, 26 Jul 2023 09:03:14 -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=20221208 header.b="Z0sm/6Yl"; 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 S234874AbjGZPP5 (ORCPT + 99 others); Wed, 26 Jul 2023 11:15:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231417AbjGZPPm (ORCPT ); Wed, 26 Jul 2023 11:15:42 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CF2319A0 for ; Wed, 26 Jul 2023 08:15:15 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2b962535808so100354031fa.0 for ; Wed, 26 Jul 2023 08:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690384512; x=1690989312; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EmHtEDaViE9w7v3YPcqZQ4Gg5qZi74veSidbXAx7Uuk=; b=Z0sm/6YlFBVHxaxcjSwwX/bHyhr+EAoV9DMvYiCLh1gzjeElQo2oiosipQdXcgFCHC Dh4l2DPNInb8wFxoVcaMu053NsAepgd8juJJfi4f77Oq8z0fvgOLujl1esBDHY59v22f II4Ew7GK+kdxPpty5uTynOE0fZn80NMl/SqI9jM4NmWlTGldJ0png0oDQtxH5YQ2jU3C YHPELzG2W5BDzAJ1G9YhcsCe6V4xvHEGxMVEG09eNkGKoa5TFPuol693V9n79qX3GuTR 7S9RI4L/pBPsq54wiwxps6KS/O679itw93JRxiFCJQL9iOnmPpwTAZkp5AOvwgnOm/En ohrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690384512; x=1690989312; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EmHtEDaViE9w7v3YPcqZQ4Gg5qZi74veSidbXAx7Uuk=; b=mF1/od83/5KQFKq17ocFmnj+P1PeKzhxDwMWU9KFWvh1BVQPa5Ci9WZzQwRP/zZ3Ao 6PNUqN+n04C7+5VIzPLXwFmByBbauz1tHrxMQBXVIjL33ZP7DqiHZPDsXgIEPxje8o+v LI3nsKqDLBJ391aUtZ1rUc9JX30ZskFHEoiS6qNvzoujx9DCQpR+/BF5xMcOEed5Npam +s2XaXbyZj2fjV+L5aOZeTznysPWPhabzcmKRq2Rv4Y690ZamjmO8g0xIj/DoQ1zNz/c dJZcbBgncv3W9ONj0OUlE3angt3+j3KpHzJWaylXWeXFusnuTo+LxrCIjgDpzrGqW6Kw 4qJA== X-Gm-Message-State: ABy/qLb15Ady69XFsJcEN5NsUO1UsqiR/CO4Wf/MrJKunMyWtBmz26p6 ncKHHnAxM+tpgPu10H1Pl2xG5v+qOBhkxWACQaBWoA== X-Received: by 2002:a2e:9d99:0:b0:2b6:e958:5700 with SMTP id c25-20020a2e9d99000000b002b6e9585700mr1811458ljj.4.1690384511813; Wed, 26 Jul 2023 08:15:11 -0700 (PDT) MIME-Version: 1.0 References: <20230726002904.655377-1-yosryahmed@google.com> <20230726002904.655377-2-yosryahmed@google.com> <20230726151315.GB1365610@cmpxchg.org> In-Reply-To: <20230726151315.GB1365610@cmpxchg.org> From: Yosry Ahmed Date: Wed, 26 Jul 2023 08:14:35 -0700 Message-ID: Subject: Re: [PATCH v2] mm: memcg: use rstat for non-hierarchical stats To: Johannes Weiner Cc: linux-kernel@vger.kernel.org, Michal Hocko , cgroups@vger.kernel.org, linux-mm@kvack.org, Muchun Song , Shakeel Butt , Roman Gushchin , Andrew Morton Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=unavailable 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 Wed, Jul 26, 2023 at 8:13=E2=80=AFAM Johannes Weiner wrote: > > On Tue, Jul 25, 2023 at 05:36:45PM -0700, Yosry Ahmed wrote: > > On Tue, Jul 25, 2023 at 5:29=E2=80=AFPM Yosry Ahmed wrote: > > > - Fix a subtle bug where updating a local counter would be missed if = it > > > was cancelled out by a pending update from child memcgs. > > > > > > Johannes, I fixed a subtle bug here and I kept your Ack, I wasn't sure > > what the Ack retention policy should be here. A quick look at the fix > > would be great. > > Ah, I found it: > > > > @@ -5542,19 +5539,23 @@ static void mem_cgroup_css_rstat_flush(struct= cgroup_subsys_state *css, int cpu) > > > memcg->vmstats->state_pending[i] =3D 0; > > > > > > /* Add CPU changes on this level since the last flush= */ > > > + delta_cpu =3D 0; > > > v =3D READ_ONCE(statc->state[i]); > > > if (v !=3D statc->state_prev[i]) { > > > - delta +=3D v - statc->state_prev[i]; > > > + delta_cpu =3D v - statc->state_prev[i]; > > > + delta +=3D delta_cpu; > > > statc->state_prev[i] =3D v; > > > } > > > > > > - if (!delta) > > > - continue; > > > - > > > /* Aggregate counts on this level and propagate upwar= ds */ > > > - memcg->vmstats->state[i] +=3D delta; > > > - if (parent) > > > - parent->vmstats->state_pending[i] +=3D delta; > > > + if (delta_cpu) > > > + memcg->vmstats->state_local[i] +=3D delta_cpu= ; > > When delta nulls out, but delta_cpu is non-zero... subtle. Yup, led to a few missed updates, was not trivial to track down :) > > This fixed version looks good, please keep my ack :) Thanks!