Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp651516rwe; Wed, 31 Aug 2022 08:43:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lGWlv6/PulL4rtfbxV/Pha+TP2skK6hsbMRQMiSd8Di336kVly22VY77PFkGziNFtCSNd X-Received: by 2002:aa7:c3c2:0:b0:447:7d68:7187 with SMTP id l2-20020aa7c3c2000000b004477d687187mr24718585edr.400.1661960600967; Wed, 31 Aug 2022 08:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661960600; cv=none; d=google.com; s=arc-20160816; b=SXWOPDTbzHhvbGqp6hDWkz0OYbcqjc0beS30JP46aIRoOU5b7IkYHAVItfkxYw23/x 0PDcNev+LhQAHPK5DT3R8aGUldkF0DxiFs3kt8s293//mVs4KBocZaIqDy0QipjyVhBm RFKn2YidW5igsdVb/MbTlwx6hkClMtpSPFHvchDmYWJ7WbUONM2zaKGOf9ltnOq9AUwl ZgzbEMAk9PHwHp+CkBxMHsa/V9oC5dUNXnFx4jGf5X24CpkMdvkWzXc3CCkjFfXXoTSt wTGZR4HVxI54E5LfswrFMB4U+RuxuhPHX8XHsQcXTURLN4maIHHvfqbShmuU7x+cD/WJ fzAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Z5bWT124P9msiKtHJxXWtamGxGE9nU7NFSbNkXeVir4=; b=sFZgcjSCU9vM+NDsdCfo5skHxzA/mANZlxSKQL2N3MKRf684/FWvHZV2/NlakqtuOp +8MtgifwO14OrsKorvFAGgmC1Gk2DxCepEUVUCEE2UqOaAFyl/o5VS7CMKrC/wDUadFb 4IePPOiRk6psGY/Rm8oXvc6x82CK5b6OJiYqnABtwtNHaqHZIRs+cfyCngLLp62CdDKO 7GRwmMD9E0oG6fwJvAddVZ28fOsoPnkkmjfngHkZG51PNvhQh2GphPYbyp4WXnkNd0OS t6BIp8z4u+/LCPzX7ByossiWfB4oyvyDkZN6qgJWyp85CwglAZEtioJD3z4FQG787nxD p31w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=q4yt7LQZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp20-20020a170906c15400b0073d21e8125dsi11070878ejc.850.2022.08.31.08.42.53; Wed, 31 Aug 2022 08:43:20 -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=@google.com header.s=20210112 header.b=q4yt7LQZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231866AbiHaPhd (ORCPT + 99 others); Wed, 31 Aug 2022 11:37:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231819AbiHaPh2 (ORCPT ); Wed, 31 Aug 2022 11:37:28 -0400 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 159A2D8E01 for ; Wed, 31 Aug 2022 08:37:27 -0700 (PDT) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-33dc31f25f9so310704717b3.11 for ; Wed, 31 Aug 2022 08:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=Z5bWT124P9msiKtHJxXWtamGxGE9nU7NFSbNkXeVir4=; b=q4yt7LQZaKZTdzRnqOfBDWuxDUawgahY2C4+8NClZrlVWpZiq8b8wuUtt2FXanHGEc GKUHZeMZM5jPluxM3gpqfRkq+ZEpQLG+BNvz98YUVO6qqcwbNq/QfwpxfY1bBqJ/PbUe qN9rURlcwiX2U8yaFrSKUwROmM3LF8ndCfS6j0AHC4HsQL8z7s2/MCCQMTRvX3Ne6rDh NX1iVO84IZTdrxORhVNpFjbUB389eDGDLX9acAC39/jQL/Xkcw+zdEhsbVQSkIB5PGSl 3MgCLAYUQZJEhdAOCDXe/UR2KtUxqwQZuMK/LjLdJHtYQZbxs0yHQAWgM70EmS5KjdKg raEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=Z5bWT124P9msiKtHJxXWtamGxGE9nU7NFSbNkXeVir4=; b=gMVOH7CQiePOOmJKyqh29eJODr+y1nq04vRXek2w5hARi1PEELlCHcFr+olvIo/RwK 9lXPlCMNDbGhgnmdUJgLplE/e7CckezRZavZx/05TR/rTsM/vS8lK5fPevC9e20qxvyT Fzv9l5lzIq4hMnQGnLKIjm/I7I9WwoGqNudqTslAExVD+R3ihse6yFT+rTZA8mA1EveB ENK70oJEDQAu18ntX4pVYKWWVKkdrCROfaPwcWtj0UWqtX4MC0FkWfettOB4ctC+zBG1 xDxcH67KQ1+CtvXsyQZGZinJxXOwUOSovZTwOvZ5bm6K59a9P2Wpnb3AGepmVeCIC4Xk PgYA== X-Gm-Message-State: ACgBeo13hMaqEf2cvqoxtPjz9pJfDcLzlZXFKuZKU5PAD1YZblbvk0Dt jLfixjD1IwSwvB2pdBi0sMr6g9lH5mtQbzPqI0yCxw== X-Received: by 2002:a81:7784:0:b0:33d:ca62:45f5 with SMTP id s126-20020a817784000000b0033dca6245f5mr18452862ywc.180.1661960245620; Wed, 31 Aug 2022 08:37:25 -0700 (PDT) MIME-Version: 1.0 References: <20220830214919.53220-1-surenb@google.com> <20220830214919.53220-4-surenb@google.com> <20220831100249.f2o27ri7ho4ma3pe@suse.de> In-Reply-To: <20220831100249.f2o27ri7ho4ma3pe@suse.de> From: Suren Baghdasaryan Date: Wed, 31 Aug 2022 08:37:14 -0700 Message-ID: Subject: Re: [RFC PATCH 03/30] Lazy percpu counters To: Mel Gorman Cc: Andrew Morton , Kent Overstreet , Michal Hocko , Vlastimil Babka , Johannes Weiner , Roman Gushchin , Davidlohr Bueso , Matthew Wilcox , "Liam R. Howlett" , David Vernet , Peter Zijlstra , Juri Lelli , Laurent Dufour , Peter Xu , David Hildenbrand , Jens Axboe , mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, changbin.du@intel.com, ytcoode@gmail.com, Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Benjamin Segall , Daniel Bristot de Oliveira , Valentin Schneider , Christopher Lameter , Pekka Enberg , Joonsoo Kim , 42.hyeyoo@gmail.com, Alexander Potapenko , Marco Elver , dvyukov@google.com, Shakeel Butt , Muchun Song , arnd@arndb.de, jbaron@akamai.com, David Rientjes , Minchan Kim , Kalesh Singh , kernel-team , linux-mm , iommu@lists.linux.dev, kasan-dev@googlegroups.com, io-uring@vger.kernel.org, linux-arch@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-modules@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" 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_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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, Aug 31, 2022 at 3:02 AM Mel Gorman wrote: > > On Tue, Aug 30, 2022 at 02:48:52PM -0700, Suren Baghdasaryan wrote: > > From: Kent Overstreet > > > > This patch adds lib/lazy-percpu-counter.c, which implements counters > > that start out as atomics, but lazily switch to percpu mode if the > > update rate crosses some threshold (arbitrarily set at 256 per second). > > > > Signed-off-by: Kent Overstreet > > Why not use percpu_counter? It has a per-cpu counter that is synchronised > when a batch threshold (default 32) is exceeded and can explicitly sync > the counters when required assuming the synchronised count is only needed > when reading debugfs. The intent is to use atomic counters for places that are not updated very often. This would save memory required for the counters. Originally I had a config option to choose which counter type to use but with lazy counters we sacrifice memory for performance only when needed while keeping the other counters small. > > -- > Mel Gorman > SUSE Labs