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: 10105877 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 0D9766025B for ; Mon, 11 Dec 2017 21:57:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B85C298E9 for ; Mon, 11 Dec 2017 21:57:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 007AF2991E; Mon, 11 Dec 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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 A2EDA298E9 for ; Mon, 11 Dec 2017 21:57:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752068AbdLKV5R (ORCPT ); Mon, 11 Dec 2017 16:57:17 -0500 Received: from mail-yb0-f193.google.com ([209.85.213.193]:43055 "EHLO mail-yb0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752501AbdLKVzn (ORCPT ); Mon, 11 Dec 2017 16:55:43 -0500 Received: by mail-yb0-f193.google.com with SMTP id i206so6904387ybc.10 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=lOibAdkxmJoeEPmdp4pU4X0pMCuS7d3SqHmzWqRgx1lpvHmSITQaynFjVH3N9BkMkt Ey3hcGYOuPEIga6JGriLM51W0+/MpLTxN7BIG3skC0RGtGtB2INFoM4XEjylbLbKXEPy 2IOLEkJKNIvNVzHYOm9dMjSQY8gCGfnb1NGg3e2Ywgiy9401D0pcl5l5aqUVGlh1Pa3w 9iOUWFpO/7yCTKLq/b7+jSTovn+M8wzI0217j7yjYmf1fjhX5gPTf752CYKsWOIxuUsm Bffwef0hg5CtB5z8/Ku0bmSp2Xi178cvLqG5JcMpaA2k7bofHBc9umYyKaEGz20nkF5Y zGVA== X-Gm-Message-State: AKGB3mII2Qlgr0zmR1ffEkOJwzVZM/zV+y3OTlHOlHvJISriNdmaoIfi SN4jr3DN8WIgJ16rEkac8NF2NIP6RCE= 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-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 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); }