Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5870260rwd; Mon, 5 Jun 2023 09:35:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5IS3OU+GXr56dJ39bQwUrL4Tl2CwoYhiJM89LM64oXt7faLuuZMsW0nSRDGZ7kKRmJbexC X-Received: by 2002:ad4:5cae:0:b0:626:1ca6:5f02 with SMTP id q14-20020ad45cae000000b006261ca65f02mr9760050qvh.9.1685982954685; Mon, 05 Jun 2023 09:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685982954; cv=none; d=google.com; s=arc-20160816; b=h7pRBK8df/GEd9NpI7XiqyAKUpPM9Cn8UTQi6Mf/VErSFvZmKdcUAsEu1SjorpjFBU JhtwxaW94BEx1S/mjMGy3E5Z4NQ+jc+In7Q3jMU4M5GyTjzSN7idUToEm05HbHTwh0gw 12JEtNEgXZpvKlkhLAuBU4LIlETavb5Y2WuMiePXXNKZrM4ga6+QasuOyQoQ/hYUWHF9 sMW8ogpQ3u9/haIXAMkzMaj3bs7eW1V5DJuKNJnEqB4PaNA8QCsEqG89SOIo6RLaIjeu MSt6VG9ZyvVU9VOiIvgn4VD0B6joz8+6JAUjhrRAUvKbTXIopLN5tAYJOP85hoNVkbOJ FsYQ== 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=aUGgVJv3OH8Y3yOfj14ZtdGxMxkCrnVBqnFI5Sr8c30=; b=Upr6hQaUgljdv2/zWOTkFYFPy7u+yTi21b7uQJt16RwzPRaaBp3nDqdTLyQS9iVrSi IPQ09bpnsdEdmEsdjtpUv9FIX8LUsj19YgGvCRcoDwfEmM4LEfSXoBxXwMnegX9tZKbO BMTCEN80taRa2jrttsF5fE9Uu5ltIXLB614GEkjzG5Gffp9wl1GbLigTEfrroS5N1+Lj evTkynbNWd9AIgXwWBii3QOsqESjZwRJGZpcEBs+OTbKcCdq7MCyMTaYzqiaTCbC0YNg Od7Wm/TBxitQ08J2wQklBN2o+U5IO/J6RmVG/agiElIhb8EJkQc0nVGSPaFuOrAKxd3E mEGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ZUasjstE; 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 g18-20020ac87f52000000b003f6b3304c34si4850519qtk.555.2023.06.05.09.35.38; Mon, 05 Jun 2023 09:35:54 -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=ZUasjstE; 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 S234365AbjFEQLM (ORCPT + 99 others); Mon, 5 Jun 2023 12:11:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234559AbjFEQLB (ORCPT ); Mon, 5 Jun 2023 12:11:01 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D76EEB0 for ; Mon, 5 Jun 2023 09:10: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-out1.suse.de (Postfix) with ESMTPS id 92CEC21B88; Mon, 5 Jun 2023 16:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1685981458; 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=aUGgVJv3OH8Y3yOfj14ZtdGxMxkCrnVBqnFI5Sr8c30=; b=ZUasjstE44mGD3twK2/4hGngTAdgMuwoNjNe5PbJljMGZuLxWP+ushB+4EoBOVTAx7L/ea wk/ZewbzR2j9Xwteyvs3VVidUKXuJVTh6e23q17yxdPtZxPoMnvPfABB2Ybp5TiGExV8ov nkW0BbR201l0Iw3F/vm5Lkr5LNwpeZI= 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 7131C139C7; Mon, 5 Jun 2023 16:10:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RW27GBIJfmQPDQAAMHmgww (envelope-from ); Mon, 05 Jun 2023 16:10:58 +0000 Date: Mon, 5 Jun 2023 18:10: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: 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 Mon 05-06-23 12:43:24, Marcelo Tosatti wrote: > On Mon, Jun 05, 2023 at 09:59:57AM +0200, Michal Hocko wrote: > > 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. > > Michal, > > Can you please check if the following looks better, as > a changelog? thanks > > --- > > schedule_work_on API uses the workqueue mechanism to > queue a work item on a queue. A kernel thread, which > runs on the target CPU, executes those work items. > > Therefore, when using the schedule_work_on API, > it is necessary for the kworker kernel thread to > be scheduled in, for the work function to be executed. > > Time sensitive applications such as SoftPLCs > (https://tum-esi.github.io/publications-list/PDF/2022-ETFA-How_Real_Time_Are_Virtual_PLCs.pdf), > have their response times affected by such interruptions. > > The /proc/sys/vm/stat_refresh file was originally introduced by > > commit 52b6f46bc163eef17ecba4cd552beeafe2b24453 > Author: Hugh Dickins > Date: Thu May 19 17:12:50 2016 -0700 > > mm: /proc/sys/vm/stat_refresh to force vmstat update > > Provide /proc/sys/vm/stat_refresh to force an immediate update of > per-cpu into global vmstats: useful to avoid a sleep(2) or whatever > before checking counts when testing. Originally added to work around a > bug which left counts stranded indefinitely on a cpu going idle (an > inaccuracy magnified when small below-batch numbers represent "huge" > amounts of memory), but I believe that bug is now fixed: nonetheless, > this is still a useful knob. No need to quote the full changelog. > Other than the potential interruption to a time sensitive application, > if using SCHED_FIFO or SCHED_RR priority on the isolated CPU, then > system hangs can occur: > > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=978688 Confused... This report says that accessing the file (i.e. to force the refresh) can get stalled because high priority tasks will not allow kworkers to run. No? There is simply no way around that unless those kworkers inherit the priority. It certainly is unfortunate that the call is not killable but being stuck behind real time busy looping processes is nothing really uncommong. One has to be really careful when using real time priorities. > To avoid the problems above, do not schedule the work to synchronize > per-CPU mm counters on isolated CPUs. Given the possibility for > breaking existing userspace applications, avoid changing > behaviour of access to /proc/sys/vm/stat_refresh, such as > returning errors to userspace. You are changing the behavior. The preexisting behavior was to flush everything. This is clearly changing that. > --- > > > 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?) > > Fail to see the point here ? I mean that, if you already want to change the semantic of the call then it would likely be safer to change it in a more robust way and only flush pcp vmstat caches that are in the process effective cpu mask. This way one can control which pcp caches to flush (e.g. those that are not on isolated CPUs or contrary those that are isolated but you can afford to flush at the specific moment). See? Now I am not saying this is the right way to go because there is still a slim chance this will break userspace expectations. Therefore I have asked why you simply do not stop any random application accessing stat_refresh in the first place. These highly specialized setups with isolated resources shouldn't run arbitrary crap, should that? What if I just start allocating memory and get the system close to OOM. I am pretty sure a small latency induced by the vmstat refreshes is the least problem you will have. So please step back and try to think whether this is actually fixing anything real before trying to change a user visible interface. -- Michal Hocko SUSE Labs