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: 10058433 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 8BE61602A7 for ; Tue, 14 Nov 2017 21:57:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CCC029A60 for ; Tue, 14 Nov 2017 21:57:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F74628609; Tue, 14 Nov 2017 21:57:29 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable 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 E079628609 for ; Tue, 14 Nov 2017 21:57:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757128AbdKNV5Z (ORCPT ); Tue, 14 Nov 2017 16:57:25 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:54070 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756834AbdKNV5C (ORCPT ); Tue, 14 Nov 2017 16:57:02 -0500 Received: by mail-qt0-f194.google.com with SMTP id n61so29678620qte.10 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=Pdg8kQiArcQQxNSEI+ChY077pqUoZhZ7mO0/R31XOOBtTFskuOptooNCfpi113YdWb jiYcNX782T2gM2LucATOZR0IRBMKuyhlUnFI96LlUk8t9gdIJnvtbfats2yVN2sEyH/6 211zw5h9DnNPMpWnYGjmJwtKk2o1surEZzjfF/6BJB1OCmSGbLSgOlKM7hP4GA4144nu QPLkZzhIbk4yfm0CTaPh1yd106WNE0Bjpg2eAnwvCTu9TtlPDpWuj/nH0jc+wgOZX/Z+ lRFcXONB1jeaCRuKOjXf6rI4rOF531tUVhZoHfcFtaTvmebZ7Oe81y+YWimjEQy29uQX FTRA== X-Gm-Message-State: AJaThX7RAJsMoNWzJ3ltq85y+k8MvahiKLaSL5ERmmLizDKlXIeO6swe nn9a8R2eecmPswbY4JzkxVV15g== 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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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); }