Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1350852ybn; Wed, 2 Oct 2019 14:52:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwq2aLwF2VxmUYzG44MIzXm7ji8yB9WpTAt06Yu8lmJGSDIG62dIZG/YNTiUSCyNU37X3Pi X-Received: by 2002:a50:c052:: with SMTP id u18mr6278847edd.88.1570053158942; Wed, 02 Oct 2019 14:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570053158; cv=none; d=google.com; s=arc-20160816; b=X3t5mhKJC6YYkD6hUbQmLXNEJmK2C0v0Mjmceoh+OPMdHmKbk1ToL8TekVqu5FyuIq 9heB3eNspgBHR3eFGG1GUQHjbLFWNMWJXFssk35b2DQ0neybb143mBzIKfLIWGQupyV+ GVaHWe6ejbt+D/lKefM4rSzmhJHeRp/dJHhhPmmlhFPTx27ScbcpdBPTH4Xor8BH2Iwc xdQDPXcpvDrAHttLd+7NU/Oni8WruWxomeG/1oBCn4QSt8aZigomw/Ul01mBlPDxgigy ip5CPUPwamEwu1wxETXf7VU5QJVNXFg4mq+pgpq3mRmFdqAtIMTedqD4wKIdjZIbKfy/ 81sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=f1uPZnw3jQ7XkJ0CCk+XRv8aHVS8VCW7XiwQkjgkuhk=; b=HS50hFmpcCvQ5DbpZPOyUgagnnwGyHw65+aKGVxJPMpvtU5yTaEwDwjEQQ52+VUx1l NEPXfQEXyppspf2nKj+pps1LMuk1BYKy5v3TEVyCqw3dL/hFiP1YUkQ75q90g2cZPwvp U7jaCnXwmUbo8didt82Tv/3iOVnA2d5WsV+8w1mnagBaYqSGlG0Jia4OtbshLVMCBrQp J1PTkLbm04ur+7Ti1xMzMeqMg0QDZo7u09Ithk6c8BVIvE7/9bW5BVQq4yWrYc9gFQNO q3uMehbXDNjeYB3P8R8viAho1OiEoI/k3Q17NJ8z4zhHHLPuWcpmY8DtNXjwTYqMx2Oh L8EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=APqGrdpd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u3si249177edy.48.2019.10.02.14.52.14; Wed, 02 Oct 2019 14:52:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=APqGrdpd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727696AbfJBU30 (ORCPT + 99 others); Wed, 2 Oct 2019 16:29:26 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:34008 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726374AbfJBU30 (ORCPT ); Wed, 2 Oct 2019 16:29:26 -0400 Received: by mail-vs1-f68.google.com with SMTP id d3so157485vsr.1 for ; Wed, 02 Oct 2019 13:29:25 -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; bh=f1uPZnw3jQ7XkJ0CCk+XRv8aHVS8VCW7XiwQkjgkuhk=; b=APqGrdpdkYEA5HmtGEspH/HP6wxxy4q59sbp1I5FOGjoRVE0ISlMc8A6+70SzcEUid kRvgxHonJJf2ee1TDY3oPKkwtpF6oIJZEu+4xupLOgZIUFc8Bnro1MJXJApbzFRIORrZ 0quYQNafcCSI5jxhN6Mnvz+rSS2mMvwYZhmQJpKHGCZjQ0EzmCCevvgvhWRDJ1hcBCaZ /3tzEcXU1RVdAPA91CPtxlXpFRS6b3mQ36TC3EaDDfXSU0LDJDwrgm1iVDOiLMb8K3Dk I1wHC15oAagULEzw9Kb8b3wmMFJkP5adrpuOU7HYEIDikER4ifmZzHH/SUxrW8SVOzH/ c8eQ== 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; bh=f1uPZnw3jQ7XkJ0CCk+XRv8aHVS8VCW7XiwQkjgkuhk=; b=U7w0ycDx9l35oA6l0kzsdNd9vPC6q5L6A6KjqrxtKd+O9FjRm72QhIQ3Idb1ydXK7q CZZinCskwsHnk2HSnX3qc4X8wwLyfLLfO3V0RDWX5ugdA9cFbSjWYuHytMKKCRaSxKfg 1NrRNT6D5+LqiEgOO5SGoXkkL8mGgoSErlC6G86zLwABS2Q1a1GOnhtR+WFJdyvfT4BQ oRuldXkGyx/2F/VmKCjVOn/dKWz1AW1eRbm9nkIQ1KKrfqppQnq1oFBnRPZ4bl8MRhQm CeT7m3GH/7F2pB5jJeFFMhGASttwOcJgBObkoqaJHI6rnz0T0Sf1/sxNQfavFLGh7o01 ibXA== X-Gm-Message-State: APjAAAW/aB2LB8B2ZyEeulseA+ZVErWLpZOJUaBJfYbkylL43V2UkeG+ NpYyDXSIn8Yi376KkJh1RBZEvYIpFXxJ3PpbeFHifw== X-Received: by 2002:a67:c81c:: with SMTP id u28mr3280729vsk.149.1570048164504; Wed, 02 Oct 2019 13:29:24 -0700 (PDT) MIME-Version: 1.0 References: <20191002202436.202731-1-dancol@google.com> In-Reply-To: <20191002202436.202731-1-dancol@google.com> From: Daniel Colascione Date: Wed, 2 Oct 2019 13:28:48 -0700 Message-ID: Subject: Re: [PATCH] Make SPLIT_RSS_COUNTING configurable To: Daniel Colascione , Tim Murray , Suren Baghdasaryan , linux-mm@vger.kernel.org, linux-kernel , linux-mm Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > diff --git a/mm/memory.c b/mm/memory.c > index b1ca51a079f2..bf557ed5ba23 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -141,7 +141,7 @@ static int __init init_zero_pfn(void) > core_initcall(init_zero_pfn); > > > -#if defined(SPLIT_RSS_COUNTING) > +#ifdef CONFIG_SPLIT_RSS_COUNTING > > void sync_mm_rss(struct mm_struct *mm) > { > @@ -177,7 +177,7 @@ static void check_sync_rss_stat(struct task_struct *task) > if (unlikely(task->rss_stat.events++ > TASK_RSS_EVENTS_THRESH)) > sync_mm_rss(task->mm); > } > -#else /* SPLIT_RSS_COUNTING */ > +#else /* CONFIG_SPLIT_RSS_COUNTING */ > > #define inc_mm_counter_fast(mm, member) inc_mm_counter(mm, member) > #define dec_mm_counter_fast(mm, member) dec_mm_counter(mm, member) > @@ -186,7 +186,7 @@ static void check_sync_rss_stat(struct task_struct *task) > { > } > > -#endif /* SPLIT_RSS_COUNTING */ > +#endif /* CONFIG_SPLIT_RSS_COUNTING */ > > /* > * Note: this doesn't free the actual pages themselves. That > -- > 2.23.0.581.g78d2f28ef7-goog >