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 AEA26C4332F for ; Wed, 4 Jan 2023 12:35:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 157B88E0002; Wed, 4 Jan 2023 07:35:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DFE98E0001; Wed, 4 Jan 2023 07:35:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC2108E0002; Wed, 4 Jan 2023 07:35:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D9A778E0001 for ; Wed, 4 Jan 2023 07:35:24 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B055F1A0C4D for ; Wed, 4 Jan 2023 12:35:24 +0000 (UTC) X-FDA: 80317062168.28.754AE90 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id B3B6F40006 for ; Wed, 4 Jan 2023 12:35:21 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JHXLnKSf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672835722; 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=5hE0oddOlBOQnUMB6h9tuFwq5zrgy0C3MFSswKsR7tU=; b=vIV/xH0JOswJnb+NqH9Crb3IlrLR6iJgqn2+YJWhxIqKfLdhMYuIMHEZO6osQ5NFryu4p/ 27hm5WNeKgPKmK18lpEffnEspsBGjKSHdEXl7sSrkV2TihMVyR56RcV7IrE7LNMPhPsADd e6J8R+KRenHWx0YUcl7DYEKNRFMuyYg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JHXLnKSf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672835722; a=rsa-sha256; cv=none; b=QkDoKCsvev+ENu+mSuk/qh5NbYavP+pVvGur6fbVz9X/Tl9rDzcxCFC6/0mvQ1f/UuuLi6 1R9BH992sBtwaQtrz1XiE/bYGmKizvyUnCTdUHbgpmyEm545Dtn4+uS7UBcffYX0xRQa7t 8GrbEz2L2BPxfu4jA+78IF4etwJwbbA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672835721; 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=JHXLnKSfK7wN7ahKm2bkVDOFYYC0phNmsX6rH8iZQqt2bhx6+o2FzimB/kgigT0YGeIclD eOryruIfBnusaSCSGKf6jkKvGkqYvijgVSjeWckz+GddW1Ypt5A+EaJD6mO8jkfmuEeRi4 jqBKG7OuMuiVNk/K5f//bReRxVY2TZc= 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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B3B6F40006 X-Stat-Signature: 6sgizkssrfei9qapr1psns96o6444kki X-HE-Tag: 1672835721-279462 X-HE-Meta: U2FsdGVkX1/It0asPIYlIrbDQoEHzsS6aF07prn8lS54eXlFYKHyLwklV5992LMzHflUBoma7cwYl+S2747LMHm78J3IvI7IB4vyid1l/0FVyRxEG5Y5qznL0BmJs8ytdduMxNAhYqJ2+GILSyQO2SJvmLC4eXc6ka+ggj7Y7tEjacupM+v8mVbYyDJlTGkrAzDKumMZxN5vixiEC/ExmUDkSbl+JNm4jqZVGD5vg1dFJM9oY9xFl75TS+Kg2akX4VYdt5MWFiejkcIqjiRA79Rwym0QYVhAxBf3zo3WJw3wmy+Mi385Ovm2TzpY1kP3dLzWDg+hV+Svc3jXN21BcdohTo5rXHIKJc2MHpLtSbDQGOu6jWKi1ZyJ/PGICZsDDiSwf9/+nrXL7VQ0HhNTykNA/4HtZ9nLKhuwnL/ihlZgoQn34nH62yC28JcoMKnrIn7/z7WSVzWFT9ggxBbLi6ibnwJ6d1/yx5nuRgxEYExnVnzgqsoeisLEpFqRNEVKLnoVag1I9ZCNAGQpazQ72rqNFWVfoxgMirk4mo5cjYDK/CKFHCIxIHPiSSIGvVpgcd6L7BKn1hWLHlhf20RSWdq6uEFefI1ocgA8ICf7Bec790/jpPyDZ9igIoCw8byaFbho2TfN7B/aZoZ4o3+3l+lmuOHDL42rPUd/YeXw4J89kiK2iRzGtFUGlOVWJaGYBh06ZUF/HgO7tO6ORTSiXrD7/lR4eOQrRWYDhKa066fdG5awGM6UdGVN1yoKokJScyyZ9bfMuQ0uAfILv2ISNP0mGBScWkVM8LMRgO/yOcR0vVFmsYbY70N478gY1SqmWjLe0mim7gvXPLgynq8B+gF2Nhcp1pk0FcK2mySC/ZzfesUr+JW8h5Tgfs2ta1LMrGRh1hDjrtN3BFqhCU8BkRcUx51F3H58kwddNsIjNXb5uam6vTrQ39+UR23VwnhYbFTGn0rLPnM= 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 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().