From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1141C433E0 for ; Wed, 6 Jan 2021 00:47:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 698B622E03 for ; Wed, 6 Jan 2021 00:47:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 698B622E03 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4D7D28D00CB; Tue, 5 Jan 2021 19:47:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 461268D006E; Tue, 5 Jan 2021 19:47:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 350BD8D00CB; Tue, 5 Jan 2021 19:47:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 20F308D006E for ; Tue, 5 Jan 2021 19:47:47 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E2950362D for ; Wed, 6 Jan 2021 00:47:46 +0000 (UTC) X-FDA: 77673512532.16.pan01_301830c274dd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id C63CF100E6903 for ; Wed, 6 Jan 2021 00:47:46 +0000 (UTC) X-HE-Tag: pan01_301830c274dd X-Filterd-Recvd-Size: 4858 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Jan 2021 00:47:46 +0000 (UTC) Received: by mail-lf1-f53.google.com with SMTP id h205so2838419lfd.5 for ; Tue, 05 Jan 2021 16:47:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RMNiD2AYhlcEkCed4y/yG9fQtf+nimzBnHckuWdc+Do=; b=Nnsz0TFWUjFmvHF4/2OXj3ES9s++zvfDXtHLLakj8ltds1BgcYY6qfyLQIYXuEg1c6 Z97RlEwab64WjFoc2dFTEZ/bn/eRI9gfPAQaZ9dZ7o9xfPnL1kKznPBG1OtsdRdWoMxX HdB0ET2V4/ZEgBv1P97iJFsf+/o8nwDSKBg7z/oZJiJtRkWzuCRqrXuziAXsud1zbiwK GzbVruqbQz8j6FLNhm2XAfRfRk5sjSjZKjJpTU6YWSqBqIDG0++5K/bAMWFzZ0Tnp8GY FqEWEdYntA7GqVtk8tMCzJkL7lwIYuqESHrZ+J0h7+Gq30nmwA3haaD9ia6t1gh2CEdc BfsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RMNiD2AYhlcEkCed4y/yG9fQtf+nimzBnHckuWdc+Do=; b=CDc5p/euGrfhQI+gZOA6CRMY8fbZ9lfsG//zB3yiVKE28UbAEXZszX9XqIR0EyRlad kg760BhZ1Uoh93Lqc0tzEqyEiRlQ+/wYBvt9Fr8wu9LgDLUfdt2f21DlApjtlooasKs3 fPpzdKUAo5plwtIH6Y37uCTxEN6qfWJjd+QgWOq/dTKiIavam4xvYkMiNJkOd6UwT1q6 rrj7qeXDOWyJS0d85QQoAWQvuvbS+gfZKZqzRpRZ20rUs6JR4IoP3oCzm4IyZgrQW0jd yIaFwxgTFwk/iNCaviKXcuKfH0g2VKQAkZIhehuWyWCp7+zQJOb3xO8AoAZncshV17pW ZFIg== X-Gm-Message-State: AOAM533lZGO4cLXebIk2596kf3kq8SDk0AWZG6JBPTrVxwhR9q+sQrfH AXUMc/YJcO2l0E977nau+kfxRU35rfHxnb5w57EQAg== X-Google-Smtp-Source: ABdhPJx6V+KDy+trQYd0fYxF2cvxQIvtVgVQcRsV69kDDgkZ6IgTLQyoYoxxud9z973lLCD7O1cO4Oge3eTykpa3ksE= X-Received: by 2002:a05:6512:20c1:: with SMTP id u1mr818859lfr.549.1609894064820; Tue, 05 Jan 2021 16:47:44 -0800 (PST) MIME-Version: 1.0 References: <1609252514-27795-1-git-send-email-feng.tang@intel.com> <1609252514-27795-2-git-send-email-feng.tang@intel.com> In-Reply-To: <1609252514-27795-2-git-send-email-feng.tang@intel.com> From: Shakeel Butt Date: Tue, 5 Jan 2021 16:47:33 -0800 Message-ID: Subject: Re: [PATCH 2/2] mm: memcg: add a new MEMCG_UPDATE_BATCH To: Feng Tang Cc: Andrew Morton , Michal Hocko , Johannes Weiner , Vladimir Davydov , Linux MM , LKML , andi.kleen@intel.com, "Chen, Tim C" , Dave Hansen , Huang Ying , Roman Gushchin Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Dec 29, 2020 at 6:35 AM Feng Tang wrote: > > When profiling memory cgroup involved benchmarking, status update > sometimes take quite some CPU cycles. Current MEMCG_CHARGE_BATCH > is used for both charging and statistics/events updating, and is > set to 32, which may be good for accuracy of memcg charging, but > too small for stats update which causes concurrent access to global > stats data instead of per-cpu ones. > > So handle them differently, by adding a new bigger batch number > for stats updating, while keeping the value for charging (though > comments in memcontrol.h suggests to consider a bigger value too) > > The new batch is set to 512, which considers 2MB huge pages (512 > pages), as the check logic mostly is: > > if (x > BATCH), then skip updating global data > > so it will save 50% global data updating for 2MB pages > > Following are some performance data with the patch, against > v5.11-rc1, on several generations of Xeon platforms. Each category > below has several subcases run on different platform, and only the > worst and best scores are listed: > > fio: +2.0% ~ +6.8% > will-it-scale/malloc: -0.9% ~ +6.2% > will-it-scale/page_fault1: no change > will-it-scale/page_fault2: +13.7% ~ +26.2% > > One thought is it could be dynamically calculated according to > memcg limit and number of CPUs, and another is to add a periodic > syncing of the data for accuracy reason similar to vmstat, as > suggested by Ying. > I am going to push back on this change. On a large system where jobs can run on any available cpu, this will totally mess up the stats (which is actually what happens on our production servers). These stats are used for multiple purposes like debugging or understanding the memory usage of the job or doing data analysis.