Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp563830rdb; Sat, 19 Aug 2023 13:19:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE66fcVX3WeselEB/fddtwLCiIPrxfvCue/r4lwGskHIpasJPGwSW672OmB9KpnV5nTz+Kt X-Received: by 2002:a05:6a21:6da5:b0:13d:d5bd:758f with SMTP id wl37-20020a056a216da500b0013dd5bd758fmr4046172pzb.6.1692476379791; Sat, 19 Aug 2023 13:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692476379; cv=none; d=google.com; s=arc-20160816; b=ZjJNVLLRhY9yXIadHiDr+XJ3aE+iwrHLVoaIvQdgHg9VelHAA8HEXKHrZAm8NXsoLX rWp4xd2MJKy8giCeHd56Vrmg0DJSbiIKkgHQytp/kpRMbRstHQvFDFqZQfop36XBsCaK U9BjqH9k9o7d4viutddUpEM6v2Pzlv0UoDUm43+twpuI10asDSnWMMWLr1bv1lZCd/1D 1+tEc1WWnxcaxnSvCuzwubLthYzFXKIdW5jvRRhZhiES62GmZd9KtquTYviVjuQRiHNn PQ+wpcBW8auShJepFCaasVa13oPCpvPEQ9MrZa/k1UzdfPDGWy4mJSn2RFFnBbz6j1ao zyIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kVVaJzAMOPLs4F5EbaziKRc8Rzjn1Gof//6KpkJlzlQ=; fh=jkPeixNZEASgpt9+/iPFqYlcCn9wFGrY+QiYNXjo5JM=; b=Nx8ojieN/fQoQS6FNQimABWKJfxD8ENnYWU0oef4YmIHAhBc31XHldcPF6kAggG0Bo QgcWNJHrKoeiLYJwUqRGXom+UowAnLlEQBfAqKfJwuloREg7chXMif+NVMiyO/PXC+5s cTgYBJKmJmc8zV+FeGIgPkiILcL1DH4jc1t2TZL20++6pI71rL6sbgm5FzBDh0DIcj7O FHuSwAB8ihgUDiocogslj5sL7kJGx0pHmIW+mxLrYC4Rhj49solgzjeKlgGqI6wsU5uH Z9lfth9gzyaS/3YMQm6fztpFTkXsf98rbtxDmYbLOImgkm6kgV9sWQpt/uHFD+OEjaxK SpQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="Vyshv/iy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y37-20020a634965000000b005572b13d228si3802575pgk.277.2023.08.19.13.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 13:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="Vyshv/iy"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B7FEBAB6B1; Sat, 19 Aug 2023 01:41:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240997AbjHPBO6 (ORCPT + 99 others); Tue, 15 Aug 2023 21:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240996AbjHPBOo (ORCPT ); Tue, 15 Aug 2023 21:14:44 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F057D211E for ; Tue, 15 Aug 2023 18:14:43 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id d75a77b69052e-40c72caec5cso157981cf.0 for ; Tue, 15 Aug 2023 18:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692148483; x=1692753283; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kVVaJzAMOPLs4F5EbaziKRc8Rzjn1Gof//6KpkJlzlQ=; b=Vyshv/iyYwR/oFEOKc1JYHMUrHXFkWIoQxeD1rRWIN0P1XogOx5MjMYvYkUY6T9etq Zyy+W6dszX02xqzVxcGnzkiWibtt560W+RPTXwER5Qmf0ZZx6l3Swf03vaNrgkidKm5V Ej/KmVtxqPaC0pd4xGzE58TL6WJ5bPesj0D801i/T+wyBZfYfcBz9gQF8xBvFFT6Vqpb uJQox/dXljUPbaHHuiQofbJMHJgJpluHl5tdkpEyPgxbT4CQBHktXf2KCsM0dFTCMBwz kn8NICYHPgpjhsrh4cNbGwSHhulF3tQ+l22DrSd/Dz81D2atgZBtsQPqUUYRbZqq3sKU di6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692148483; x=1692753283; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kVVaJzAMOPLs4F5EbaziKRc8Rzjn1Gof//6KpkJlzlQ=; b=ihefUlEWWTwxH+BFx4pFxC9omndWVIZjU4STx1IdNua5h7+D93LOJ79v/6ZhENaCFb s/IhFVnB5PVY9mjeoDMdwBr2+Q5LMuGk3wc2Dd8HHwK4mxEA79qS1dKvSvBoovwjsPPg iAx8TMWhR5DAJtnP5gMjGbMnqXVIB3hOJa08qvWmqpmexY+d8hcRmSGyt2wWvdIF8SVD 7IkMNMqFjSFizBQjwyL3dLRKmZx1azLB/8/IZNCON0oMXM2yanad7KbJrpULorwwEEqz 6scJwoy62QZl+FAih8L67K7xEOl5jOd/BnFwsbi3k7izF0azYtPVRNrJpVzQV+D8ec3j 1nfA== X-Gm-Message-State: AOJu0Yz89K9JUauDAiZcblmv4OnkS0ohRWaUuTrG0hlB1/HnSGQ4Kb4I DEPO2cQTZIx4gYgWae1RDCR5Z/3Fy/xgSLSWksZFCg== X-Received: by 2002:ac8:4e86:0:b0:3f5:2006:50f1 with SMTP id 6-20020ac84e86000000b003f5200650f1mr130504qtp.12.1692148483063; Tue, 15 Aug 2023 18:14:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shakeel Butt Date: Tue, 15 Aug 2023 18:14:30 -0700 Message-ID: Subject: Re: [PATCH] mm: memcg: provide accurate stats for userspace reads To: Yosry Ahmed Cc: Tejun Heo , Michal Hocko , Johannes Weiner , Roman Gushchin , Andrew Morton , Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ivan Babrou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Tue, Aug 15, 2023 at 5:29=E2=80=AFPM Yosry Ahmed = wrote: > [...] > > > > I thought we already reached the decision on how to proceed here. Let > > me summarize what I think we should do: > > > > 1. Completely remove the sync flush from stat files read from userspace= . > > 2. Provide a separate way/interface to explicitly flush stats for > > users who want more accurate stats and can pay the cost. This is > > similar to the stat_refresh interface. > > 3. Keep the 2 sec periodic stats flusher. > > I think this solution is suboptimal to be honest, I think we can do bette= r. > > With recent improvements to spinlocks/mutexes, and flushers becoming > sleepable, I think a better solution would be to remove unified > flushing and let everyone only flush the subtree they care about. Sync > flushing becomes much better (unless you're flushing root ofc), and > concurrent flushing wouldn't cause too many problems (ideally no > thundering herd, and rstat lock can be dropped at cpu boundaries in > cgroup_rstat_flush_locked()). > > If we do this, stat reads can be much faster as Ivan demonstrated with > his patch that only flushes the cgroup being read, and we do not > sacrifice accuracy as we never skip flushing. We also do not need a > separate interface for explicit refresh. > > In all cases, we need to keep the 2 sec periodic flusher. What we need > to figure out if we remove unified flushing is: > > 1. Handling stats_flush_threshold. > 2. Handling flush_next_time. > > Both of these are global now, and will need to be adapted to > non-unified non-global flushing. The only thing we are disagreeing on is (1) the complete removal of sync flush and an explicit flush interface versus (2) keep doing the sync flush of the subtree. To me (1) seems more optimal particularly for the server use-case where a node controller reads stats of root and as well as cgroups of a couple of top levels (we actually do this internally). Doing flush once explicitly and then reading the stats for all such cgroups seems better to me.