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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49F49C46467 for ; Tue, 10 Jan 2023 12:11:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232432AbjAJMLq (ORCPT ); Tue, 10 Jan 2023 07:11:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238151AbjAJMLM (ORCPT ); Tue, 10 Jan 2023 07:11:12 -0500 Received: from gentwo.de (gentwo.de [161.97.139.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AB1C848CE for ; Tue, 10 Jan 2023 04:08:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gentwo.de; s=default; t=1673351912; bh=447xrWnDqvwlUVdeSyRqpMKeorpuhhxwz0VX/chL6q4=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=OQdljGZJ7GEaR+2T0y2kTi4JRaIidDrAhbBtRiwLY1g6Tn7oFLTGivZm/lMhfr950 AhsWj14TGatRgkkTh68n+6T6xbMynu3m5ib4Z/waZKDvdDDqdtoEhhELYXPQap9O77 Fw/UGoQ+wtntKA96aBps0Un6+y7U3JRUdAcfckf4gMb3TYdUVH7oKBhDm9ljXRMe5J I8Xs09inSfKfZD7hEEBapr4DpvkO1pZf5Z06hyPPNGeaZu6yd8t/iZ5zqeXzA4E/mC 9QSmtJNgT4hXnPRFtLuFz5jmZRyexjOGN06ifMc5SiYKs7PxgIOaEb2Nexv/Tno1Ts MV+naO0HGB9Wg== Received: by gentwo.de (Postfix, from userid 1001) id B32AAB001C8; Tue, 10 Jan 2023 12:58:32 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by gentwo.de (Postfix) with ESMTP id B1C18B00101; Tue, 10 Jan 2023 12:58:32 +0100 (CET) Date: Tue, 10 Jan 2023 12:58:32 +0100 (CET) From: Christoph Lameter To: Marcelo Tosatti cc: atomlin@atomlin.com, frederic@kernel.org, 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 v13 1/6] mm/vmstat: Add CPU-specific variable to track a vmstat discrepancy In-Reply-To: <20230105125248.772766288@redhat.com> Message-ID: References: <20230105125218.031928326@redhat.com> <20230105125248.772766288@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Jan 2023, Marcelo Tosatti wrote: > +static inline void vmstat_mark_dirty(void) > +{ > + this_cpu_write(vmstat_dirty, true); > +} this_cpu_write() is intended for an per cpu atomic context. You are not using it in that way. The processor may have changed before or after and thus vmstat_dirty for another CPU may have been marked dirty. I guess this would have to be called __vmstat_mark_dirty() and be using __this_cpu_write(*) with a requirement that preemption be disabled before using this function. > +static inline void vmstat_clear_dirty(void) > +{ > + this_cpu_write(vmstat_dirty, false); > +} Same > +static inline bool is_vmstat_dirty(void) > +{ > + return this_cpu_read(vmstat_dirty); > +} This function would only work correctly if preemption is disabled. Otherwise the processor may change.