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 D6D8FC6FA8E for ; Thu, 2 Mar 2023 21:17:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 182586B0075; Thu, 2 Mar 2023 16:17:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 10B3C6B0078; Thu, 2 Mar 2023 16:17:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9EC96B007B; Thu, 2 Mar 2023 16:17:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D93A36B0075 for ; Thu, 2 Mar 2023 16:17:23 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9B848A0DCA for ; Thu, 2 Mar 2023 21:17:23 +0000 (UTC) X-FDA: 80525219166.19.50C88A9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 9402710000D for ; Thu, 2 Mar 2023 21:17:21 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PQuDxKpd; spf=pass (imf14.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677791841; a=rsa-sha256; cv=none; b=NaQ5/thKw8wbBjzCY5tgT8eKQ3BNWaKh2BdCBBq3i+k5XjD88EEms/TNegMQyoijSP7ISg EJ9VdwDXq1+AiYw1jBz1qfpOcg/lJc6lGz4sg/DYuCS0lqreyBpEBYneJ/dn5gqJx6TkUh QC8u6AUAG0VGYtpuMMq/ERtVn/ZP27g= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PQuDxKpd; spf=pass (imf14.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677791841; 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=jlr3DPbhmz+YnZeWV0ifc3qyeasTfNTJ9iJvKosFhgg=; b=jTZjPCTY9hisfYVhj51KQLeaMDBxsXXWrBOsJ6sfXgklJlStfaM+NA07XFLzrws4i+jQcM 3gJxiFfoCzzqM1muTCkjl9Z6Ym7BdkC7G173uYkqNBsAT7UrM/VQ/jbjqoEiQq/wri322V 69NxMui8g0pfVLTmpMx3ZisGXEvhdZM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677791841; 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=jlr3DPbhmz+YnZeWV0ifc3qyeasTfNTJ9iJvKosFhgg=; b=PQuDxKpdrjGHh4tjY7HrFsDxbRK50YrERg1b0WMvUqAzZu2RfJcsgMYc7OjNZjGOaFDWjY pTSuvm0PkeCjLE+qkjiAnrd4io2wj4mdAjD1zCOhh6bkgeXTHWygjqpYIAO+x0Xcqt2nao WNrg0BerrIDRyNicpUj5gri7LVKvAWg= 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-367-egb84iHhOmOmmjwdOe72nQ-1; Thu, 02 Mar 2023 16:17:19 -0500 X-MC-Unique: egb84iHhOmOmmjwdOe72nQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26F70101A52E; Thu, 2 Mar 2023 21:17:19 +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 DE2422026D4B; Thu, 2 Mar 2023 21:17:18 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 7442440135051; Thu, 2 Mar 2023 18:16:42 -0300 (-03) Date: Thu, 2 Mar 2023 18:16:42 -0300 From: Marcelo Tosatti To: Peter Xu Cc: Christoph Lameter , Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 10/11] mm/vmstat: switch vmstat shepherd to flush per-CPU counters remotely Message-ID: References: <20230209150150.380060673@redhat.com> <20230209153204.901518530@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspam-User: X-Rspamd-Queue-Id: 9402710000D X-Rspamd-Server: rspam01 X-Stat-Signature: bkwki6s8nu69somo64gdpnyq3r95abda X-HE-Tag: 1677791841-325272 X-HE-Meta: U2FsdGVkX19nO5m/JCpTvvpzVd6UaktbQ05ZHtQjFA/UqSJ1HN5m45W4kuuY3y2NHzODA0iTFfpo/Eu9/L5ZU3JvTWphJ0HfV2PnxS6npd47bSaTLU37yRnfxNbEd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kKUdDtMBO3NvPBNq28TncNKr8tWJPM= 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 Thu, Mar 02, 2023 at 04:01:07PM -0500, Peter Xu wrote: > On Thu, Feb 09, 2023 at 12:02:00PM -0300, Marcelo Tosatti wrote: > > +#ifdef CONFIG_HAVE_CMPXCHG_LOCAL > > +/* Flush counters remotely if CPU uses cmpxchg to update its per-CPU counters */ > > +static void vmstat_shepherd(struct work_struct *w) > > +{ > > + int cpu; > > + > > + cpus_read_lock(); > > + for_each_online_cpu(cpu) { > > + cpu_vm_stats_fold(cpu); > > Nitpick: IIUC this line is the only change with CONFIG_HAVE_CMPXCHG_LOCAL > to replace the queuing. Would it be cleaner to move the ifdef into > vmstat_shepherd, then, and keep the common logic? https://lore.kernel.org/lkml/20221223144150.GA79369@lothringen/ Could have #ifdef CONFIG_HAVE_CMPXCHG_LOCAL int cpu_flush_vm_stats(int cpu) { return cpu_vm_stats_fold(cpu); } #else int cpu_flush_vm_stats(int cpu) { struct delayed_work *dw = &per_cpu(vmstat_work, cpu); if (!delayed_work_pending(dw) && need_update(cpu)) queue_delayed_work_on(cpu, mm_percpu_wq, dw, 0); } #endif static void vmstat_shepherd(struct work_struct *w) { int cpu; cpus_read_lock(); for_each_online_cpu(cpu) { cpu_flush_vm_stats(cpu); cond_resched(); } cpus_read_unlock(); schedule_delayed_work(&shepherd, round_jiffies_relative(sysctl_stat_interval)); } This looks really awkward to me. But then, we don't want schedule_delayed_work if !CONFIG_HAVE_CMPXCHG_LOCAL. The common part would be the cpus_read_lock and for_each_online_cpu loop. So it seems the current separation is quite readable (unless you have a suggestion). > > + cond_resched(); > > + } > > + cpus_read_unlock(); > > + > > + schedule_delayed_work(&shepherd, > > + round_jiffies_relative(sysctl_stat_interval)); > > +} > > +#else > > static void vmstat_shepherd(struct work_struct *w) > > { > > int cpu; > > @@ -2026,6 +2043,7 @@ static void vmstat_shepherd(struct work_ > > schedule_delayed_work(&shepherd, > > round_jiffies_relative(sysctl_stat_interval)); > > } > > +#endif > > > > static void __init start_shepherd_timer(void) > > { > > > > > > > > -- > Peter Xu > >