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: 10071071 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 7DC95601D5 for ; Wed, 22 Nov 2017 21:16:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FE1529D67 for ; Wed, 22 Nov 2017 21:16:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64C9329DA0; Wed, 22 Nov 2017 21:16:21 +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 10CFD29D67 for ; Wed, 22 Nov 2017 21:16:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752170AbdKVVQT (ORCPT ); Wed, 22 Nov 2017 16:16:19 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:46221 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752152AbdKVVQP (ORCPT ); Wed, 22 Nov 2017 16:16:15 -0500 Received: by mail-qt0-f193.google.com with SMTP id r39so25526806qtr.13 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=P9bBHUq+4aMoLimXdDzFzbO3zdqZUxWO9JWvRwUUcgQClyWbHj6vJhX8srEgbg8Zrq SQLfdch33mdatn5W5NzYOekXjZasbhyRksjedmpQBl+GuZgqFJqhLCy6U86SzOB1Xcp1 QfW12I85P2SPcOitW4Zrvpfh9qlGsvIkwsGNBSDMhf4CsncEXHi36gPujt7pm7w9oAe9 C6dxOismhc0R+e2clPkhXWdP5k3qgXest0vA2HiJ8IAlY/mKfuzE2kTzY6R9mE9QAVsS G/1qrQr1MjvA+So3NSasG6OdCYjZpXyMSNprnoJoUHcF/0CIZUeUX7k6uXzmTpqr0vsz AKbg== X-Gm-Message-State: AJaThX6UqnJ13nfUw2PkNWVrjmlMZ/2bGFkewC+1KtHRS1hXwixl9T2c NGyHstjKcLgJAWWsRzK78e/06XJT7oc= 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-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 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); }