From patchwork Tue Nov 14 21:56:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10058429 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 858D8602A7 for ; Tue, 14 Nov 2017 21:57:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77F6428609 for ; Tue, 14 Nov 2017 21:57:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C9C629A74; Tue, 14 Nov 2017 21:57:23 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 0995028609 for ; Tue, 14 Nov 2017 21:57:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757241AbdKNV5T (ORCPT ); Tue, 14 Nov 2017 16:57:19 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:46959 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756836AbdKNV5D (ORCPT ); Tue, 14 Nov 2017 16:57:03 -0500 Received: by mail-qt0-f194.google.com with SMTP id 1so29694484qtn.3 for ; Tue, 14 Nov 2017 13:57:03 -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=coR0scusrJY6BW3mymLYHiAFhOdZNljty/6R3y/3Wac=; b=TCwTHNg7xj7gOAKKgHvjD2z3dVAGMtmkei0MwKCI2Hah6o3nO7cMV888T1TAeUCckN 1BIZQEuHfb5eFMG3i2d75e5ks3fK0p+y73w7SFoIobBtk0NmCpjGkCl178WjT3XJgE5W y9o2N+9jmKTtYi2gbaoHd6qOkP3BLIfQ6EYnxYRClCRGgZ5ncD6piLz0liwlysdiuJD7 sCZ+Ayyubj+5gS3qrJLQhpMEAniFiQBK/jWhWwf6NchHYe7ZqN7V8eX/wdtikal18FiE ooZCjSQnITYCComCwoShczYRhaykqHmHRt+er3ZIvyfBovzoVJ1OUgyyGaDop4JRWQHp 5wUw== 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=coR0scusrJY6BW3mymLYHiAFhOdZNljty/6R3y/3Wac=; b=Y0GbDucDWgHBXrn+123ptYrqGwSwZ7mjaRCdtqTBXUZgAFL4I1MXZFj3tO90UV6Heg Zq2tnbVeTWvPqk7cNgOZ/2nhwJcTKOUshmuB9dbNMseiv++Z+76SKn2qEaPrBZ+vBRBW d8alf2kW8mM4UmHlj4HZZ5JjF0+96Ss8Wksdu1Gnt0p59zzALu5u9GJ4yzAlzJwGTPk4 vOJkBR9/Ta5ifXVz3uq0HdePf5kGDaInSLn9/5+E+564c7tA3HW0f+MljkY7v9TG62vs i9yMp5KGFU/7dSK8i0O2q48RhIznuklaoi7oymz98FvBzaEyfoYmN/E+569pAihtfk4i JnPg== X-Gm-Message-State: AJaThX6Xuk5XuMDKZNQnPU6lUEWRWNMniMzfu7yUhkF4muklqMkAci18 G2N2qPC/rgDSog3Djm8wy5stBg== X-Google-Smtp-Source: AGs4zMaV/ua/ZL0wcEJkYL3NafyREekSCmVyi0sg/SGXEHYSTmX8k0hc8DaWLLrV+1YGR1IWiAtFpQ== X-Received: by 10.55.76.85 with SMTP id z82mr22393606qka.346.1510696622618; Tue, 14 Nov 2017 13:57:02 -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 v21sm13602669qtv.21.2017.11.14.13.57.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Nov 2017 13:57:02 -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 04/10] lib: add a __fprop_add_percpu_max Date: Tue, 14 Nov 2017 16:56:50 -0500 Message-Id: <1510696616-8489-4-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 This helper allows us to add an arbitrary amount to the fprop structures. Signed-off-by: Josef Bacik --- 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 853f4305d1b2..2d1a87331e5d 100644 --- a/include/linux/flex_proportions.h +++ b/include/linux/flex_proportions.h @@ -85,8 +85,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); @@ -101,4 +101,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 5552523b663a..2190180a81fe 100644 --- a/lib/flex_proportions.c +++ b/lib/flex_proportions.c @@ -254,8 +254,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; @@ -266,6 +267,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, p->batch_size); - percpu_counter_add(&p->events, 1); + percpu_counter_add_batch(&pl->events, nr, p->batch_size); + percpu_counter_add(&p->events, nr); }