Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13180052rwl; Wed, 4 Jan 2023 04:48:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXtejyY73AqED0LIvAxaKMy0XzTF0CDe84I9oof28Do+vRbRisuL4aLp8TjNuWszOmuzXxZP X-Received: by 2002:a05:6a20:492a:b0:af:6cc0:344d with SMTP id ft42-20020a056a20492a00b000af6cc0344dmr50724420pzb.18.1672836538552; Wed, 04 Jan 2023 04:48:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672836538; cv=none; d=google.com; s=arc-20160816; b=fEUgvNFaCVsycyKFIOyYLlGYkS4UlOL7NhWt/mpr+7ZiRiI+PLcB7PY/n9nfVNvGJs O38ClY0dK7rClAVoTjrrS9iG8szawmVba0MnXFiMa8szXb3IU9mU76AcdYmw1lhboPXV L/KY/W5pw/Cv0gspUO47IC9PAWBaenNigsHdNxrvZX1WQT0tdzKJ1ykpb0SBYSuUTBwp /Tqfxx4GWMiNeBNTZC1k0LJNv9xPQureGpaPWNxYQyf8QGNvvuZbjMhy4SP3iEezSHqN llWS47LtC6d+h09lDqCLTGT3hoUWqLBYyzxveE0+nz5GVBTBAVk880MN3bI+P/zZJgSF nbHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5hE0oddOlBOQnUMB6h9tuFwq5zrgy0C3MFSswKsR7tU=; b=XwkV+WRxkAp7oD+P3vbQ/Zl1Qh7DvPtiK9HgHZSHcesZlRAz52etyl1SGl1AFsiP5D QGJv9eyVJ9kWNqs1IL7idhoopguPeBg5VXg3tAdwlyz7/7oOhgHbu89dG11sHRhp/ptH vCcGu8SMzASaA/CGvKVdLlJ1Nt5zyLOLl25VsrOV2W2v0ekh3k3FJhwY4OWvIVCELn8R e413heItsppLHmN9Sv+PQYzt+mBzV9p41E+d4HtfL/kmTfk8y79DdXQ6SvrnK48cmzPO 2wPS4R60ZzFgUoLN7iZCEP+Dfiv8ebN1FlP4QhdBQGpYh6Mf7Yl4Bwrpltm0QyPADEkk R1nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RXJOEQ5a; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p33-20020a635b21000000b004921cae2a13si34207091pgb.151.2023.01.04.04.48.51; Wed, 04 Jan 2023 04:48:58 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=RXJOEQ5a; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239227AbjADMgZ (ORCPT + 57 others); Wed, 4 Jan 2023 07:36:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239171AbjADMf7 (ORCPT ); Wed, 4 Jan 2023 07:35:59 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DCF21AA1B for ; Wed, 4 Jan 2023 04:35:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672835716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5hE0oddOlBOQnUMB6h9tuFwq5zrgy0C3MFSswKsR7tU=; b=RXJOEQ5aC3Q1QQWY1sj/g2VbWdauWadQ0d6jIfQLMCrYuR50GjLyok+CNlFf9W1S14fUnh lKL3RkHNzf7XeDN33cUO0E9ywVhDTgu9jDfCI9S/flfR8hkqbwqAbE5RiYoMhpk4xQ30cj vrFw7bMr87Pc6tLpAJFNVcglp7m/tqc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-634-Y0jQp5o0PgWBlBJf02lrsQ-1; Wed, 04 Jan 2023 07:35:15 -0500 X-MC-Unique: Y0jQp5o0PgWBlBJf02lrsQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 41451101A52E; Wed, 4 Jan 2023 12:35:15 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCD8949BB6A; Wed, 4 Jan 2023 12:35:14 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id DF24C400E5705; Sat, 31 Dec 2022 21:38:04 -0300 (-03) Date: Sat, 31 Dec 2022 21:38:04 -0300 From: Marcelo Tosatti To: Frederic Weisbecker Cc: atomlin@atomlin.com, cl@linux.com, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, pauld@redhat.com, neelx@redhat.com, oleksandr@natalenko.name, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v12 2/6] mm/vmstat: Use vmstat_dirty to track CPU-specific vmstat discrepancies Message-ID: References: <20221227121137.102497574@redhat.com> <20221227121341.981235373@redhat.com> <20221230132132.GA186035@lothringen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221230132132.GA186035@lothringen> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Fri, Dec 30, 2022 at 02:21:32PM +0100, Frederic Weisbecker wrote: > On Tue, Dec 27, 2022 at 09:11:39AM -0300, Marcelo Tosatti wrote: > > @@ -606,6 +608,7 @@ static inline void mod_zone_state(struct > > > > if (z) > > zone_page_state_add(z, zone, item); > > + vmstat_mark_dirty(); > > } > > > > void mod_zone_page_state(struct zone *zone, enum zone_stat_item item, > > @@ -674,6 +677,7 @@ static inline void mod_node_state(struct > > > > if (z) > > node_page_state_add(z, pgdat, item); > > + vmstat_mark_dirty(); > > Looking at this further, about the two above chunks, there is a risk to > mark the wrong CPU dirty because those functions are preemptible and rely > on this_cpu_cmpxchg() to deal with preemption. > > Thanks. Hi Frederic, Yes, good catch: if the CPU is preempted after this_cpu_cmpxchg(), but before vmstat_mark_dirty, then one ends up with a CPU with per-CPU vm counters dirty and the per-CPU vmstat dirty bit unset. This could cause a CPU to remain with the per-CPU vm counters dirty for longer than sysctl_stat_interval. Should move vmstat_mark_dirty() above "if (z)", then do preempt_disable() on function entry and preempt_enable() after vmstat_mark_dirty. Luckily preempt_disable()/preempt_enable() is much cheaper than local_irq_disable()/local_irq_enable().