Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5303221rwd; Mon, 5 Jun 2023 01:18:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/W7u7eysGMJFOE6cLKsYyjfkvslH+Zjmb8Cj4jOUyxY61GvpI82fV21Z7JcpqSzbZMMCg X-Received: by 2002:a05:6102:148:b0:43b:4872:f619 with SMTP id a8-20020a056102014800b0043b4872f619mr567275vsr.2.1685953082173; Mon, 05 Jun 2023 01:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685953082; cv=none; d=google.com; s=arc-20160816; b=W8AV+Gt46+d1CDxnZ8Zynrd8bBpQTMdU9BIR3I6/+W6fwZCH57JK3C4h7DXlRySNjy 1wIZK69Qf4UmWp/xY4VuKR8FglKmRTH+CJLle/s3f9yp34uHJyRY2SzEp1QqguOs6KCI jwTYRagC7PdaWMVMpHE9VXKq8yZ3s3RiVZnyS258dwrcPZfHsHKYLodg6NvP+ZxAc0kF TTqTNuKKY1OWqRIri4IoI+G9WiZ24AfU4K1UYYQLb96xFBpYOYSyfxrwNJLMF50WuOep S0QWgm7zaOnd6ISpCEoXqF8hOWHnG+WbrTHxvKgL7Aqf47H+zNGXEpP/Y/yZDfx3+I5S 4lRA== 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=i4L3g+MtdfsEoM7Bo/IRfMUnuKT+xcWapx0/jpEiQr8=; b=eVgQpPBDtlIpsecimS0qqKrwnqNBWnSQzC4a+XLFvg/UjTk6pnaQeLdgoPaGuKwOj6 yPboSz6l5VwkKBkaiqGFlkFl0SQjjGTpyhCg5DaMx+/xvsvvgiIHt/KPElC/Z4k3EX/6 X6eBd+z3MIc5IWiobt4QZtk3dBftmY0MVKRkRZqn/V2EV0T7KWvodc2gdUyC/TMHxLUO 0sJIo5feSP9OFbC/O30ewPcuWEWNDEmWIuSELvhoKOstdGbuAjo3MputgFOBoU4bSLPS y4N/g+PBFrYrMUsxesLQW+IIrBXpGEMR11QikkFQcOzhEV7RGi7w4khj8PUrdGSHgzd8 CxaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=PEbxtQuZ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j75-20020a636e4e000000b0053490e8df50si5141681pgc.223.2023.06.05.01.17.49; Mon, 05 Jun 2023 01:18:02 -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=@suse.com header.s=susede1 header.b=PEbxtQuZ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230480AbjFEIAN (ORCPT + 99 others); Mon, 5 Jun 2023 04:00:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231793AbjFEIAA (ORCPT ); Mon, 5 Jun 2023 04:00:00 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 681CF9E for ; Mon, 5 Jun 2023 00:59:59 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 22C6C1F8AE; Mon, 5 Jun 2023 07:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1685951998; h=from:from:reply-to: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=i4L3g+MtdfsEoM7Bo/IRfMUnuKT+xcWapx0/jpEiQr8=; b=PEbxtQuZZK8xEzBZGkDd8Q1N6IoKPhhS09HcpzZaVndMt0l3SLhgM0jLdqm18oeM5xu4MO unjLitffz9hUIE6hrk60LGuZUubTXenrTAxz4+PdlvivRMv3GaxrzSrBSGizxp8TaYjAcH UeiKwBvlsObSYgOdwA3+OHdRzwIx9G4= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 018A4139C8; Mon, 5 Jun 2023 07:59:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sPPmOP2VfWRUewAAMHmgww (envelope-from ); Mon, 05 Jun 2023 07:59:57 +0000 Date: Mon, 5 Jun 2023 09:59:57 +0200 From: Michal Hocko To: Marcelo Tosatti Cc: Christoph Lameter , Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Vlastimil Babka Subject: Re: [PATCH v2 3/3] mm/vmstat: do not refresh stats for nohz_full CPUs Message-ID: References: <20230602185757.110910188@redhat.com> <20230602190115.545766386@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230602190115.545766386@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 02-06-23 15:58:00, Marcelo Tosatti wrote: > The interruption caused by queueing work on nohz_full CPUs > is undesirable for certain aplications. This is not a proper changelog. I am not going to write a changelog for you this time. Please explain why this is really needed and why this approach is desired. E.g. why don't you prevent userspace from refreshing stats if interference is not desirable. Also would it make some sense to reduce flushing to cpumask of the calling process? (certainly a daring thought but have you even considered it?) > Fix by not refreshing per-CPU stats of nohz_full CPUs. > > Signed-off-by: Marcelo Tosatti > > --- > v2: opencode schedule_on_each_cpu (Michal Hocko) > > Index: linux-vmstat-remote/mm/vmstat.c > =================================================================== > --- linux-vmstat-remote.orig/mm/vmstat.c > +++ linux-vmstat-remote/mm/vmstat.c > @@ -1881,8 +1881,13 @@ int vmstat_refresh(struct ctl_table *tab > void *buffer, size_t *lenp, loff_t *ppos) > { > long val; > - int err; > int i; > + int cpu; > + struct work_struct __percpu *works; > + > + works = alloc_percpu(struct work_struct); > + if (!works) > + return -ENOMEM; > > /* > * The regular update, every sysctl_stat_interval, may come later > @@ -1896,9 +1901,24 @@ int vmstat_refresh(struct ctl_table *tab > * transiently negative values, report an error here if any of > * the stats is negative, so we know to go looking for imbalance. > */ > - err = schedule_on_each_cpu(refresh_vm_stats); > - if (err) > - return err; > + cpus_read_lock(); > + for_each_online_cpu(cpu) { > + struct work_struct *work; > + > + if (cpu_is_isolated(cpu)) > + continue; > + work = per_cpu_ptr(works, cpu); > + INIT_WORK(work, refresh_vm_stats); > + schedule_work_on(cpu, work); > + } > + > + for_each_online_cpu(cpu) { > + if (cpu_is_isolated(cpu)) > + continue; > + flush_work(per_cpu_ptr(works, cpu)); > + } > + cpus_read_unlock(); > + free_percpu(works); > for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) { > /* > * Skip checking stats known to go negative occasionally. > -- Michal Hocko SUSE Labs