From patchwork Tue Nov 14 21:56:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10058427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51AE4602A7 for ; Tue, 14 Nov 2017 21:57:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 446DE28609 for ; Tue, 14 Nov 2017 21:57:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 394E029A74; Tue, 14 Nov 2017 21:57:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4B9528609 for ; Tue, 14 Nov 2017 21:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757235AbdKNV5M (ORCPT ); Tue, 14 Nov 2017 16:57:12 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:43565 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756833AbdKNV5C (ORCPT ); Tue, 14 Nov 2017 16:57:02 -0500 Received: by mail-qt0-f193.google.com with SMTP id r58so5770052qtc.0 for ; Tue, 14 Nov 2017 13:57:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ebEA2zHE+FtmMgmrJXuYDST8kZ/l+x5rte0tf72hjVo=; b=sX95oa6dUMpz/FGqxbUxQYRyf62vVDWIFGf7XumGJ17GmPHuPPlfecyt63gIBgH3tI Pk96EsFRLxqEYSSAjkr99yqt9UpjBGi18Tg42ZsHooqmWIYY05t8B4YoAl1vdIoT+Qsn aUMbGDtqq0nbsk5gvbfHEMoIWa279s+8DtJIw49Lz1umgnQqjYs0SJXucvdpfUm6r4LI jMTRYquppbf3HWq4kOILPXlgomaKHrsVqwyTgS+O/yVx3holM2z8+M1TaduC7zXIpq/d bVH2gU20RgeZC5Q+pOdLjeC3fP7s8XUwT2aIZVXbW+euCyZFr7U+WJ2jdCm8eYmi/7Qa rH3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ebEA2zHE+FtmMgmrJXuYDST8kZ/l+x5rte0tf72hjVo=; b=B8KMinNpjtWg7f1w0W255nnG6Tujr1rXmJ3pq5l8AQhPNm5CcJMz2Y4i1+jRVy+DKw xhovJdNju0S0A9WjELpwxfNpD0yuCUY+CrCqtC61rovmGFWT8LebNDLgx4EGhI5NQywK 6L2wFXtdOrWwx9AjzfpV+SKqBKphxKB6Ckt4yINqTdIs0uM9r/oBoEFjMv1mTYqYFDGi WSCiQRYMz6tAxv4/4mkDcIYPmtrvxDmZNLHq/WoY/7GfufmxDzuQMuzrmwbDq5EK4C8s W/S57qTsr9cLXlWvROlK8NoGh3k/dTcBmGXQSCxD9A9G8IJB+QH7Xd77HLjqWR6VfWpa Efhw== X-Gm-Message-State: AJaThX6Hxp/4/WAsOO70eBReIvOY8ic+8f83LAfXU2/JH06InY/WHZqx sSxSMgfgeHyJpd2zHUu5deChVA== X-Google-Smtp-Source: AGs4zMYlX36lz/EzPEIug6qtn1TyiLNGPBTwMVm6qOklxuvkedYTxRtOWDbwHwTuXWIXXjJIYJIGjQ== X-Received: by 10.55.190.195 with SMTP id o186mr21929908qkf.7.1510696621404; Tue, 14 Nov 2017 13:57:01 -0800 (PST) Received: from localhost (cpe-2606-A000-4381-1201-225-22FF-FEB3-E51A.dyn6.twc.com. [2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id o26sm13710834qto.16.2017.11.14.13.57.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Nov 2017 13:57:00 -0800 (PST) From: Josef Bacik To: hannes@cmpxchg.org, linux-mm@kvack.org, akpm@linux-foundation.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, kernel-team@fb.com, linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 03/10] lib: add a batch size to fprop_global Date: Tue, 14 Nov 2017 16:56:49 -0500 Message-Id: <1510696616-8489-3-git-send-email-josef@toxicpanda.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1510696616-8489-1-git-send-email-josef@toxicpanda.com> References: <1510696616-8489-1-git-send-email-josef@toxicpanda.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Bacik The flexible proportion stuff has been used to track how many pages we are writing out over a period of time, so counts everything in single increments. If we wanted to use another base value we need to be able to adjust the batch size to fit our the units we'll be using for the proportions. Signed-off-by: Josef Bacik --- include/linux/flex_proportions.h | 4 +++- lib/flex_proportions.c | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/linux/flex_proportions.h b/include/linux/flex_proportions.h index 0d348e011a6e..853f4305d1b2 100644 --- a/include/linux/flex_proportions.h +++ b/include/linux/flex_proportions.h @@ -20,7 +20,7 @@ */ #define FPROP_FRAC_SHIFT 10 #define FPROP_FRAC_BASE (1UL << FPROP_FRAC_SHIFT) - +#define FPROP_BATCH_SIZE (8*(1+ilog2(nr_cpu_ids))) /* * ---- Global proportion definitions ---- */ @@ -31,6 +31,8 @@ struct fprop_global { unsigned int period; /* Synchronization with period transitions */ seqcount_t sequence; + /* batch size */ + s32 batch_size; }; int fprop_global_init(struct fprop_global *p, gfp_t gfp); diff --git a/lib/flex_proportions.c b/lib/flex_proportions.c index 2cc1f94e03a1..5552523b663a 100644 --- a/lib/flex_proportions.c +++ b/lib/flex_proportions.c @@ -44,6 +44,7 @@ int fprop_global_init(struct fprop_global *p, gfp_t gfp) if (err) return err; seqcount_init(&p->sequence); + p->batch_size = FPROP_BATCH_SIZE; return 0; } @@ -166,8 +167,6 @@ void fprop_fraction_single(struct fprop_global *p, /* * ---- PERCPU ---- */ -#define PROP_BATCH (8*(1+ilog2(nr_cpu_ids))) - int fprop_local_init_percpu(struct fprop_local_percpu *pl, gfp_t gfp) { int err; @@ -204,11 +203,11 @@ static void fprop_reflect_period_percpu(struct fprop_global *p, if (period - pl->period < BITS_PER_LONG) { s64 val = percpu_counter_read(&pl->events); - if (val < (nr_cpu_ids * PROP_BATCH)) + if (val < (nr_cpu_ids * p->batch_size)) val = percpu_counter_sum(&pl->events); percpu_counter_add_batch(&pl->events, - -val + (val >> (period-pl->period)), PROP_BATCH); + -val + (val >> (period-pl->period)), p->batch_size); } else percpu_counter_set(&pl->events, 0); pl->period = period; @@ -219,7 +218,7 @@ static void fprop_reflect_period_percpu(struct fprop_global *p, void __fprop_inc_percpu(struct fprop_global *p, struct fprop_local_percpu *pl) { fprop_reflect_period_percpu(p, pl); - percpu_counter_add_batch(&pl->events, 1, PROP_BATCH); + percpu_counter_add_batch(&pl->events, 1, p->batch_size); percpu_counter_add(&p->events, 1); } @@ -267,6 +266,6 @@ void __fprop_inc_percpu_max(struct fprop_global *p, return; } else fprop_reflect_period_percpu(p, pl); - percpu_counter_add_batch(&pl->events, 1, PROP_BATCH); + percpu_counter_add_batch(&pl->events, 1, p->batch_size); percpu_counter_add(&p->events, 1); }