Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6067077rwl; Wed, 22 Mar 2023 06:12:31 -0700 (PDT) X-Google-Smtp-Source: AK7set/AnNOJv/C74x5lveM1ukk0+5UoPXdudPTk3VRXpgn0+r/j9peQ9vkoj3qv8VI2zr/V5kSv X-Received: by 2002:a05:6a20:9c:b0:da:4e05:760 with SMTP id 28-20020a056a20009c00b000da4e050760mr4201541pzg.55.1679490751019; Wed, 22 Mar 2023 06:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679490751; cv=none; d=google.com; s=arc-20160816; b=Gs+nvdpwOFwTERlVVSWRT6SKnRlD08kHZO0zsy2FAQaJYzoOB+aBwLMfnUsZwq3fRr hp68+0LJGpdAQPnCgRRSM5cf+kJyVCwUZ0LyAIFz39jvp4K2E7bTyg+fXyp8rhqTSFSE L8YgDAl0kq4PUCQfKK9zJk+Gtfm93BbYOIdUt92cu5EmCduORY2dgQK8MvlRGDs0c9Uk GCMrKPwJAKx1iLcfRh6KPgfjWwRDdIFUJLS+N6UA19rIS1iO5+jC7T/8shm34RxKLVXN us6V9AVtdyL7Texv51JCyXRngZyx2SmHlDFV2SsDpgm9UgWGAhzQv9IHSUWG9eMzL97+ mRIg== 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=tExFdmCiqdw4UNq5+xUg0Bj+oy59LS9aN6+JsFo6iIc=; b=qN15ISUlHlBkwF746QKOXRFXAgVVqAdbtrf1GZLv5912xjPY8DM3UH4Cidxh2/Yrfx oP1dAH4/dX4DiXzjTnN0iiVUvpZ4mbDqF7ZXolufwCNzDU33rE3GnmONi42OnN8ytxLf Kq+eQBUdw9/vpnUh+JcTusol5U854VtNd4DYwmyWDMxerfhrCx6Dn47AS797eixxg2uW dl6w5xvWy8vRvSCvp5Hwc8Mi1rnPnws0IPPOL3JartgkaAshVHCMniTzqiBWbE6PbqjV ZwVb1JgDNwkqo1GOYegmbFMLYJh3hOdeFgsY/GEkPEJF6+PyM6aWOQEqf+enT9fqWfvn k+yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Hb9W+Bal; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b35-20020a631b63000000b00509d00f18efsi15525240pgm.112.2023.03.22.06.12.19; Wed, 22 Mar 2023 06:12:30 -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=@redhat.com header.s=mimecast20190719 header.b=Hb9W+Bal; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230252AbjCVNKG (ORCPT + 99 others); Wed, 22 Mar 2023 09:10:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229871AbjCVNKF (ORCPT ); Wed, 22 Mar 2023 09:10:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 830A85FEAE for ; Wed, 22 Mar 2023 06:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679490554; 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=tExFdmCiqdw4UNq5+xUg0Bj+oy59LS9aN6+JsFo6iIc=; b=Hb9W+BalA2glqRZKTvOO0piFDGmMc2MdJAAa6vQJ95tRLkW4+31JDlfiwRjnnx4OrSBeCy EPoTMPgFdF/37AsUfzUFmIoBl2SLAJyw4QD05Ts3C047TveU91M+5h1gpi4Udtg37PeYtP fBuuEJszW/ODufAEElRjj9WvnfDltWA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-389-ObtzlDwgOputjLC5rvWu3w-1; Wed, 22 Mar 2023 09:09:11 -0400 X-MC-Unique: ObtzlDwgOputjLC5rvWu3w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 924492812949; Wed, 22 Mar 2023 13:09:10 +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 1899C492C13; Wed, 22 Mar 2023 13:09:10 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 1CC9A400E055B; Wed, 22 Mar 2023 08:23:21 -0300 (-03) Date: Wed, 22 Mar 2023 08:23:21 -0300 From: Marcelo Tosatti To: Michal Hocko Cc: Christoph Lameter , Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Russell King , Huacai Chen , Heiko Carstens , x86@kernel.org, Vlastimil Babka Subject: Re: [PATCH v7 00/13] fold per-CPU vmstats remotely Message-ID: References: <20230320180332.102837832@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.9 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=unavailable 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 Wed, Mar 22, 2023 at 11:13:02AM +0100, Michal Hocko wrote: > On Mon 20-03-23 16:07:29, Marcelo Tosatti wrote: > > On Mon, Mar 20, 2023 at 07:25:55PM +0100, Michal Hocko wrote: > > > On Mon 20-03-23 15:03:32, Marcelo Tosatti wrote: > > > > This patch series addresses the following two problems: > > > > > > > > 1. A customer provided evidence indicating that a process > > > > was stalled in direct reclaim: > > > > > > > This is addressed by the trivial patch 1. > > > > > > [...] > > > > 2. With a task that busy loops on a given CPU, > > > > the kworker interruption to execute vmstat_update > > > > is undesired and may exceed latency thresholds > > > > for certain applications. > > > > > > Yes it can but why does that matter? > > > > It matters for the application that is executing and expects > > not to be interrupted. > > Those workloads shouldn't enter the kernel in the first place, no? It depends on the latency requirements and individual system calls. > Otherwise the in kernel execution with all the direct or indirect > dependencies (e.g. via locks) can throw any latency expectations off the > window. > > > > > By having vmstat_shepherd flush the per-CPU counters to the > > > > global counters from remote CPUs. > > > > > > > > This is done using cmpxchg to manipulate the counters, > > > > both CPU locally (via the account functions), > > > > and remotely (via cpu_vm_stats_fold). > > > > > > > > Thanks to Aaron Tomlin for diagnosing issue 1 and writing > > > > the initial patch series. > > > > > > > > > > > > Performance details for the kworker interruption: > > > > > > > > oslat 1094.456862: sys_mlock(start: 7f7ed0000b60, len: 1000) > > > > oslat 1094.456971: workqueue_queue_work: ... function=vmstat_update ... > > > > oslat 1094.456974: sched_switch: prev_comm=oslat ... ==> next_comm=kworker/5:1 ... > > > > kworker 1094.456978: sched_switch: prev_comm=kworker/5:1 ==> next_comm=oslat ... > > > > > > > > The example above shows an additional 7us for the > > > > > > > > oslat -> kworker -> oslat > > > > > > > > switches. In the case of a virtualized CPU, and the vmstat_update > > > > interruption in the host (of a qemu-kvm vcpu), the latency penalty > > > > observed in the guest is higher than 50us, violating the acceptable > > > > latency threshold for certain applications. > > > > > > I do not think we have ever promissed any specific latency guarantees > > > for vmstat. These are statistics have been mostly used for debugging > > > purposes AFAIK. I am not aware of any specific user space use case that > > > would be latency sensitive. Your changelog doesn't go into details there > > > either. > > > > There is a class of workloads for which response time can be > > of interest. MAC scheduler is an example: > > > > https://par.nsf.gov/servlets/purl/10090368 > > Yes, I am not disputing low latency workloads in general. I am just > saying that you haven't really established a very sound justification > here. The -v7 cover letter was updated with additional details, as you requested (perhaps you missed it): "Performance details for the kworker interruption: oslat 1094.456862: sys_mlock(start: 7f7ed0000b60, len: 1000) oslat 1094.456971: workqueue_queue_work: ... function=vmstat_update ... oslat 1094.456974: sched_switch: prev_comm=oslat ... ==> next_comm=kworker/5:1 ... kworker 1094.456978: sched_switch: prev_comm=kworker/5:1 ==> next_comm=oslat ... The example above shows an additional 7us for the oslat -> kworker -> oslat switches. In the case of a virtualized CPU, and the vmstat_update interruption in the host (of a qemu-kvm vcpu), the latency penalty observed in the guest is higher than 50us, violating the acceptable latency threshold for certain applications." > Of course there are workloads which do not want to conflict with > any in kernel house keeping. Those have to be configured and implemented > very carefully though. Vmstat as such should not collide with those > workloads as long as they do not interact with the kernel in a way > counters are updated. Is this hard or impossible to avoid? The practical problem we have been seeing is -RT app initialization. For example: 1) mlock(); 2) enter loop without system calls > I can imagine that those workloads have an start up sequence where the > kernel is involved and counters updated so that deferred flushing could > interfere with the later and latency sensitive phase. Is that a real > problem in practice? Please tell us much more why we need to make the > vmstat code more complex. Yes, it is. I have attached traces and performance numbers above.