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=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham 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 2FA23C4360C for ; Thu, 3 Oct 2019 02:08:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DB2E121A4C for ; Thu, 3 Oct 2019 02:08:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ovk93Uox" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB2E121A4C 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 782476B0006; Wed, 2 Oct 2019 22:08:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 708136B0007; Wed, 2 Oct 2019 22:08:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F6876B0008; Wed, 2 Oct 2019 22:08:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 3BD4B6B0006 for ; Wed, 2 Oct 2019 22:08:55 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 96E9C824CA16 for ; Thu, 3 Oct 2019 02:08:54 +0000 (UTC) X-FDA: 76000840188.21.farm73_4dbaade60365a X-HE-Tag: farm73_4dbaade60365a X-Filterd-Recvd-Size: 7513 Received: from mail-vs1-f67.google.com (mail-vs1-f67.google.com [209.85.217.67]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Oct 2019 02:08:54 +0000 (UTC) Received: by mail-vs1-f67.google.com with SMTP id d204so594154vsc.12 for ; Wed, 02 Oct 2019 19:08:53 -0700 (PDT) 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=bCQGlGZ8Y+oVDG1Ma6bLrg91foqSNXoF97NZ5ZFwA/Q=; b=Ovk93Uox7JXnsQtTFYgx2Nsi6AhN0kIgTPhfn9/Ibu3FWsaIoNsskyitFtm9f8MS/Y GsUw61dgeePnDZEMKu/fDvcsVbMQDn8Dnyx6kv6k10smk4yKuXecq2x/iX2gopVCgOWn 2akggopW8lb7P4ztlteq7SpOJpSzawaocQkuCzcuL15bSzdqQlHTGySJ/kQWq66thRXy ypkvq/Ulvidr3YtZ2tfEG4s5txrnFE73oWSBNuCM1CYgop4kGmWa3JuJx1TcOXnSz3td o4/ppDp2yLaGKiLXp3hZZxwzd6WIeiQ9eckn7yI7KEsiEoB6YbNV7lovQJ5huOGVXNS1 /RGg== 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=bCQGlGZ8Y+oVDG1Ma6bLrg91foqSNXoF97NZ5ZFwA/Q=; b=BtCZEcpkAlyhRRXzraMPEZY5INmb7kkUY8PyuKlkBegSytuSFvhjJ3CaridQ/r+xy0 JE1L9wYCDFvDK2dFX7IgdVQ81Jt3FnPwySU02/pIMoOdTjeLT6CB+XvPrdUXx892q87i +FARUDEuZ1VgEzrgvbx5igVwoLzR1acvU2F9lBnz9p1/ejtODrWEPpWjo+Ub6ifjUl9M OGewhjR34JUqXPQRHj2+WUwm+Jbb4I9GgHhmg6ZYeQGCeR/Qz9np81jocXMLMwEp0MuD +E+ad3PPiGfmTsvRWaXng1S8jDxws8YU7li/8F0u7eS3iwnB/nWW9o22xQ7zA6SA/MWx Y1lg== X-Gm-Message-State: APjAAAUjSxYtCG9k3hLsbG6cuUlTZZ0C6FClj44fATKLynq95WCyUI3m FCl2G+DxT7Fcai0MJjWVxLRhBLhpKjGWEdeVtpF6og== X-Google-Smtp-Source: APXvYqyi0m2Ede72KrDlWODF8m+LzvY0aTakQKoIvxaf/PDUucc/aAOF/PTV+/ueCyA8VW2bLR96Ab0ft94lN+2AmtQ= X-Received: by 2002:a67:f0cd:: with SMTP id j13mr3958561vsl.183.1570068532914; Wed, 02 Oct 2019 19:08:52 -0700 (PDT) MIME-Version: 1.0 References: <1C584B5C-E04E-4B04-A3B5-4DC8E5E67366@lca.pw> In-Reply-To: <1C584B5C-E04E-4B04-A3B5-4DC8E5E67366@lca.pw> From: Daniel Colascione Date: Wed, 2 Oct 2019 19:08:16 -0700 Message-ID: Subject: Re: [PATCH] Make SPLIT_RSS_COUNTING configurable To: Qian Cai Cc: Tim Murray , Suren Baghdasaryan , linux-mm@vger.kernel.org, linux-kernel , linux-mm 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 Wed, Oct 2, 2019 at 6:56 PM Qian Cai wrote: > > On Oct 2, 2019, at 4:29 PM, Daniel Colascione wrote: > > > > Adding the correct linux-mm address. > > > > > >> On Wed, Oct 2, 2019 at 1:25 PM Daniel Colascione wrote: > >> > >> Using the new config option, users can disable SPLIT_RSS_COUNTING to > >> get increased accuracy in user-visible mm counters. > >> > >> Signed-off-by: Daniel Colascione > >> --- > >> include/linux/mm.h | 4 ++-- > >> include/linux/mm_types_task.h | 5 ++--- > >> include/linux/sched.h | 2 +- > >> kernel/fork.c | 2 +- > >> mm/Kconfig | 11 +++++++++++ > >> mm/memory.c | 6 +++--- > >> 6 files changed, 20 insertions(+), 10 deletions(-) > >> > >> diff --git a/include/linux/mm.h b/include/linux/mm.h > >> index cc292273e6ba..221395de3cb4 100644 > >> --- a/include/linux/mm.h > >> +++ b/include/linux/mm.h > >> @@ -1637,7 +1637,7 @@ static inline unsigned long get_mm_counter(struct mm_struct *mm, int member) > >> { > >> long val = atomic_long_read(&mm->rss_stat.count[member]); > >> > >> -#ifdef SPLIT_RSS_COUNTING > >> +#ifdef CONFIG_SPLIT_RSS_COUNTING > >> /* > >> * counter is updated in asynchronous manner and may go to minus. > >> * But it's never be expected number for users. > >> @@ -1723,7 +1723,7 @@ static inline void setmax_mm_hiwater_rss(unsigned long *maxrss, > >> *maxrss = hiwater_rss; > >> } > >> > >> -#if defined(SPLIT_RSS_COUNTING) > >> +#ifdef CONFIG_SPLIT_RSS_COUNTING > >> void sync_mm_rss(struct mm_struct *mm); > >> #else > >> static inline void sync_mm_rss(struct mm_struct *mm) > >> diff --git a/include/linux/mm_types_task.h b/include/linux/mm_types_task.h > >> index c1bc6731125c..d2adc8057e65 100644 > >> --- a/include/linux/mm_types_task.h > >> +++ b/include/linux/mm_types_task.h > >> @@ -48,14 +48,13 @@ enum { > >> NR_MM_COUNTERS > >> }; > >> > >> -#if USE_SPLIT_PTE_PTLOCKS && defined(CONFIG_MMU) > >> -#define SPLIT_RSS_COUNTING > >> +#ifdef CONFIG_SPLIT_RSS_COUNTING > >> /* per-thread cached information, */ > >> struct task_rss_stat { > >> int events; /* for synchronization threshold */ > >> int count[NR_MM_COUNTERS]; > >> }; > >> -#endif /* USE_SPLIT_PTE_PTLOCKS */ > >> +#endif /* CONFIG_SPLIT_RSS_COUNTING */ > >> > >> struct mm_rss_stat { > >> atomic_long_t count[NR_MM_COUNTERS]; > >> diff --git a/include/linux/sched.h b/include/linux/sched.h > >> index 2c2e56bd8913..22f354774540 100644 > >> --- a/include/linux/sched.h > >> +++ b/include/linux/sched.h > >> @@ -729,7 +729,7 @@ struct task_struct { > >> /* Per-thread vma caching: */ > >> struct vmacache vmacache; > >> > >> -#ifdef SPLIT_RSS_COUNTING > >> +#ifdef CONFIG_SPLIT_RSS_COUNTING > >> struct task_rss_stat rss_stat; > >> #endif > >> int exit_state; > >> diff --git a/kernel/fork.c b/kernel/fork.c > >> index f9572f416126..fc5e0889922b 100644 > >> --- a/kernel/fork.c > >> +++ b/kernel/fork.c > >> @@ -1917,7 +1917,7 @@ static __latent_entropy struct task_struct *copy_process( > >> p->vtime.state = VTIME_INACTIVE; > >> #endif > >> > >> -#if defined(SPLIT_RSS_COUNTING) > >> +#ifdef CONFIG_SPLIT_RSS_COUNTING > >> memset(&p->rss_stat, 0, sizeof(p->rss_stat)); > >> #endif > >> > >> diff --git a/mm/Kconfig b/mm/Kconfig > >> index a5dae9a7eb51..372ef9449924 100644 > >> --- a/mm/Kconfig > >> +++ b/mm/Kconfig > >> @@ -736,4 +736,15 @@ config ARCH_HAS_PTE_SPECIAL > >> config ARCH_HAS_HUGEPD > >> bool > >> > >> +config SPLIT_RSS_COUNTING > >> + bool "Per-thread mm counter caching" > >> + depends on MMU > >> + default y if NR_CPUS >= SPLIT_PTLOCK_CPUS > >> + help > >> + Cache mm counter updates in thread structures and > >> + flush them to visible per-process statistics in batches. > >> + Say Y here to slightly reduce cache contention in processes > >> + with many threads at the expense of decreasing the accuracy > >> + of memory statistics in /proc. > >> + > >> endmenu > > All those vague words are going to make developers almost impossible to decide the right selection here. It sounds like we should kill SPLIT_RSS_COUNTING at all to simplify the code as the benefit is so small vs the side-effect? Killing SPLIT_RSS_COUNTING would be my first choice; IME, on mobile and a basic desktop, it doesn't make a difference. I figured making it a knob would help allay concerns about the performance impact in more extreme configurations.