From patchwork Wed Nov 22 21:15:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10071073 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 227EB601D5 for ; Wed, 22 Nov 2017 21:16:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1490529D67 for ; Wed, 22 Nov 2017 21:16:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 095F529DA0; Wed, 22 Nov 2017 21:16:22 +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 B278829D67 for ; Wed, 22 Nov 2017 21:16:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751621AbdKVVQS (ORCPT ); Wed, 22 Nov 2017 16:16:18 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:38218 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752096AbdKVVQP (ORCPT ); Wed, 22 Nov 2017 16:16:15 -0500 Received: by mail-qt0-f194.google.com with SMTP id q13so14125889qtb.5 for ; Wed, 22 Nov 2017 13:16:15 -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=8szFchDk0YDEGBF+6AK4kGxoowiZ0NauH/EHlQSXxzQ=; b=009P0QM20J5EgaS17EeNhcIUlQ2lljCdR42pZMNTCvWJGuRXKAwNCHw/Sy/G8JmAPf vYRM4bfCWNYxUfGFjqeaL0YEmHRCR9KSQVRpzvGNh+cb/mbRKskXbidByCmaEpmmKbRu 5Qxz7vkYO5kFuotd0TFTLIxFZP6XvaNvzhWp9obLPTvkKtIQc9H+wQZ8NnV5qQgVUqVR B0NNLvzqhqF4ORiZhZ+6fauQ3nC8EEmVqh5tqQd2kNW/gmSRqOSJ/Mk361QUkySyF1en RGoKs1tD8JdQmLGWh4q0sgVPcXxlYzMjZkWckFaLYPAlO8ZhRig7Dw9QC0UB5APihljg J5kQ== 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=8szFchDk0YDEGBF+6AK4kGxoowiZ0NauH/EHlQSXxzQ=; b=gVtQNVuIcVLHZYTnJwkCZoQl2Fz0CwUnyT9NuKxaRW3FGSTiK7twJfKXsEDy9ZwXPl bGk56dSC5Ck3WAdOSaseLCfbZzPsjLXnJ5qGzjdrDY5nsjuidtF05fCVZ/wTxBMDmOob 5DMiNT9b7MSE5958I3TZpJI5bigQkh9IemYzGZth4qzyitgr00zB4l2ZTGErCdfFpW7p M1Amedv2RIWFgvE3DnY4fZ9FJqVm5ppp4HtUu4fOvE5cYWsXBLAI2UbgNTV2L4oMjRn0 apDNBmFTxe64ODl3ZNVeXw4s+Z/HW+0LrgM3P5S4MVqV2QMhumjKuj91FEeiIoBuZHy5 1CmQ== X-Gm-Message-State: AJaThX6BwK/Bq/JleM0kxFMpk5jW0fZH2A39PD6PkWJmZvA4nmu7VTqg 1gNeTf4eHh0+6YXomzUBMjM/Pw== X-Google-Smtp-Source: AGs4zMbrmcPeQYZM7jaNctNIodDa4IGQzoFTTf4fE+L5DUXoJg6OAGuVZcnVEp4m++7soeKq33lFSQ== X-Received: by 10.200.26.108 with SMTP id q41mr36522573qtk.7.1511385374931; Wed, 22 Nov 2017 13:16:14 -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 k21sm11648221qta.27.2017.11.22.13.16.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Nov 2017 13:16:14 -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 v2 04/11] lib: add a __fprop_add_percpu_max Date: Wed, 22 Nov 2017 16:15:59 -0500 Message-Id: <1511385366-20329-5-git-send-email-josef@toxicpanda.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1511385366-20329-1-git-send-email-josef@toxicpanda.com> References: <1511385366-20329-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 b0343ae71f5e..fd95791a2c93 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); }