From patchwork Mon Dec 11 21:55:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10105843 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 EED2E6025B for ; Mon, 11 Dec 2017 21:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECC51298E9 for ; Mon, 11 Dec 2017 21:55:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E18682991E; Mon, 11 Dec 2017 21:55:54 +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 83670298E9 for ; Mon, 11 Dec 2017 21:55:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752572AbdLKVzw (ORCPT ); Mon, 11 Dec 2017 16:55:52 -0500 Received: from mail-yb0-f194.google.com ([209.85.213.194]:41483 "EHLO mail-yb0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752435AbdLKVzn (ORCPT ); Mon, 11 Dec 2017 16:55:43 -0500 Received: by mail-yb0-f194.google.com with SMTP id x83so2011978ybg.8 for ; Mon, 11 Dec 2017 13:55:43 -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=N7uNpWD5+DHvex5qVCfweKbF/dE7GMx3fvGUqMsxeig=; b=gxsnmDqog9P2GjEFPccXJ86vRSJAQRoYT8wIK4Ee1H3bOTJlqr6SXGSpGdRNX9oPHD vk2Qv444VQdAyUTDv9ki23Rchi2iwZmvzcqpT27x3I3JGF4NeYWkXgN3SpnKZw1WQTjp p76PaNMyCwLbobaZuSKkliVwlhqN1OCX7QWfVxWzfUFz+d+HhM8ocxsMDLzuXy3NSw/y byyJQ8thLInnuADhsHLewQzSyKVKCsZ0yaFv9b1WkLY5oWZsWFYKlGrIy/zbYk5BsKCL MSUDicJSJTnSlOyGxDot5g+lfMl0TtBE49Aa5FB2sU4hud4z+b/B3V46P6sqrR1ngFhK q7AA== 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=N7uNpWD5+DHvex5qVCfweKbF/dE7GMx3fvGUqMsxeig=; b=QoN3wQVckPVfTb8obQ7wtIthLM0ZHUMrR7X0ZdkTvriRDH96I3HpCN7Qxb6K8rmyTl ywoh2DK+D/Bmc/FWn68lmjeivWdtOqvq5UTzO/Ta9+ZFcMxyuN/wFOSTKpxNdv2ns6C4 PIyZQPd4IwbYDkKs02g9RG/gEB9w7K8oJhW/JaQsnpCIr2ewxx07u5KgkKhCQnsHqWyx plsFZkgEGwN8MeNYahikDaAbzxEhiyP9F+nqRqwv1+cqGFiN5YJHIr2P3RAfDm2ffIj0 gtpJOT/RYbcAZBc767czrABWoFfFaMjxuDSxp7+TSH9NU6zmMfnPfmnu1iUBsSB39Hxn hA6g== X-Gm-Message-State: AKGB3mLfa2DtYItFgfsQiqbf4tSOJjFNI/1JH6kMB4k0gFiFixlH4pM3 0hdzqssM6GrtIKGsySHnaRmi9g== X-Google-Smtp-Source: ACJfBospVzoGj/TVB9M0d+6t8ISpXlnuW6kXBcunEs8LhFkOQhO4dzMfyu2FEJYxryUSbbSmznT/Kw== X-Received: by 10.37.97.151 with SMTP id v145mr1429605ybb.106.1513029342983; Mon, 11 Dec 2017 13:55:42 -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 e128sm6757244ywf.104.2017.12.11.13.55.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 13:55:42 -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 v3 03/10] lib: add a __fprop_add_percpu_max Date: Mon, 11 Dec 2017 16:55:28 -0500 Message-Id: <1513029335-5112-4-git-send-email-josef@toxicpanda.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1513029335-5112-1-git-send-email-josef@toxicpanda.com> References: <1513029335-5112-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 This helper allows us to add an arbitrary amount to the fprop structures. Signed-off-by: Josef Bacik Reviewed-by: Jan Kara --- include/linux/flex_proportions.h | 11 +++++++++-- lib/flex_proportions.c | 9 +++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/linux/flex_proportions.h b/include/linux/flex_proportions.h index 0d348e011a6e..9f88684bf0a0 100644 --- a/include/linux/flex_proportions.h +++ b/include/linux/flex_proportions.h @@ -83,8 +83,8 @@ struct fprop_local_percpu { int fprop_local_init_percpu(struct fprop_local_percpu *pl, gfp_t gfp); void fprop_local_destroy_percpu(struct fprop_local_percpu *pl); void __fprop_inc_percpu(struct fprop_global *p, struct fprop_local_percpu *pl); -void __fprop_inc_percpu_max(struct fprop_global *p, struct fprop_local_percpu *pl, - int max_frac); +void __fprop_add_percpu_max(struct fprop_global *p, struct fprop_local_percpu *pl, + unsigned long nr, int max_frac); void fprop_fraction_percpu(struct fprop_global *p, struct fprop_local_percpu *pl, unsigned long *numerator, unsigned long *denominator); @@ -99,4 +99,11 @@ void fprop_inc_percpu(struct fprop_global *p, struct fprop_local_percpu *pl) local_irq_restore(flags); } +static inline +void __fprop_inc_percpu_max(struct fprop_global *p, + struct fprop_local_percpu *pl, int max_frac) +{ + __fprop_add_percpu_max(p, pl, 1, max_frac); +} + #endif diff --git a/lib/flex_proportions.c b/lib/flex_proportions.c index 2cc1f94e03a1..31003989d34a 100644 --- a/lib/flex_proportions.c +++ b/lib/flex_proportions.c @@ -255,8 +255,9 @@ void fprop_fraction_percpu(struct fprop_global *p, * Like __fprop_inc_percpu() except that event is counted only if the given * type has fraction smaller than @max_frac/FPROP_FRAC_BASE */ -void __fprop_inc_percpu_max(struct fprop_global *p, - struct fprop_local_percpu *pl, int max_frac) +void __fprop_add_percpu_max(struct fprop_global *p, + struct fprop_local_percpu *pl, unsigned long nr, + int max_frac) { if (unlikely(max_frac < FPROP_FRAC_BASE)) { unsigned long numerator, denominator; @@ -267,6 +268,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(&p->events, 1); + percpu_counter_add_batch(&pl->events, nr, PROP_BATCH); + percpu_counter_add(&p->events, nr); }