Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3044851pxk; Mon, 7 Sep 2020 01:13:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6uptUF+ZTDrDozj4YZEqI14/nVRp+dLnMrP/KQpgrnro7lKR6tabYMd7nKYgX6bCAR6wk X-Received: by 2002:a17:906:756:: with SMTP id z22mr6949620ejb.31.1599466414188; Mon, 07 Sep 2020 01:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599466414; cv=none; d=google.com; s=arc-20160816; b=hf/lPXtoSjM/c1H1vhGJK9TF6USMWqkbSbA2Iqtr0uxRw7p8ai13yNyHV6RexfvqtP jzbTtYIv5udWTsrQjZWDBfRzqHWdXGNZuKP8VqPAJ44MoSd2y2XJPPRY2fzEvW9LXoC+ t+zCdQZSdTMhgHygfJ1I0DGW/x29eSyUTSvEWpxO6IyydZiA/G4q/Ri/PwaGAURhNt9Q qH/8XJLTAKQpYIcEC3MERUvMABHPlVH6QNRGevPz225AeEuZ5bnX7bJXrCe3N7Fs+zE+ FVd+G3EzFNw5wWCJd1rszkbRS+stwX9Iu3bKol3FT7QmOXOzeuOaeuekaPQOI9lMn9zj 8QkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=Z//pxx4WpMxb/ZziEgRCzKnePvn6jytkaLb6d/v9uPk=; b=LlF4ljM7aa3i8qdRtpn/XI3yZeFAvUj799aE2Ed5zqgMl/Pu4VBoihVGP4iQwrzVsR 0OOekyf6k1X/2Acyxmws6d/ift/1cbdoOEbAV9F+u1nphH3fgUkg/2koOyl/V2nvo/zi IpgkeKrovlvC58GavsCEk0nw0NjhDsKEGk2IBaF+DcCJ8IRj5rcKySrPz6fc76Wq/7lZ /tOmdT9Pat69Kxe8+a7aG2G069JwOMtlghcS2h9W33NDABvmS+PpWIrorssL2LllpX2K XEsVV1C9+bv0f0cHlYXz4DTgb9BJPVNYqgN/OLhzBwqFhffKqc9yalLE0QPgRF3g7aH7 Jx6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w9si8476285eds.522.2020.09.07.01.13.11; Mon, 07 Sep 2020 01:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727874AbgIGIMG (ORCPT + 99 others); Mon, 7 Sep 2020 04:12:06 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:37517 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727116AbgIGILO (ORCPT ); Mon, 7 Sep 2020 04:11:14 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0U89GXWL_1599466230; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0U89GXWL_1599466230) by smtp.aliyun-inc.com(127.0.0.1); Mon, 07 Sep 2020 16:10:30 +0800 From: Baolin Wang To: tj@kernel.org, axboe@kernel.dk Cc: baolin.wang@linux.alibaba.com, baolin.wang7@gmail.com, linux-block@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] blk-throttle: Define readable macros instead of static variables Date: Mon, 7 Sep 2020 16:10:15 +0800 Message-Id: <0a1c4f411da22feeafe08d06472a807e2c68fff9.1599458244.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 'throtl_grp_quantum' and 'throtl_quantum' are both read-only variables, thus better to use readable macros instead of static variables, which can also save some spaces for .bss area. Signed-off-by: Baolin Wang --- block/blk-throttle.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 06e73ed..ca9002d 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -15,10 +15,10 @@ #include "blk-cgroup-rwstat.h" /* Max dispatch from a group in 1 round */ -static int throtl_grp_quantum = 8; +#define THROTL_GRP_QUANTUM 8 /* Total max dispatch from all groups in one round */ -static int throtl_quantum = 32; +#define THROTL_QUANTUM 32 /* Throttling is performed over a slice and after that slice is renewed */ #define DFL_THROTL_SLICE_HD (HZ / 10) @@ -1175,8 +1175,8 @@ static int throtl_dispatch_tg(struct throtl_grp *tg) { struct throtl_service_queue *sq = &tg->service_queue; unsigned int nr_reads = 0, nr_writes = 0; - unsigned int max_nr_reads = throtl_grp_quantum*3/4; - unsigned int max_nr_writes = throtl_grp_quantum - max_nr_reads; + unsigned int max_nr_reads = THROTL_GRP_QUANTUM * 3 / 4; + unsigned int max_nr_writes = THROTL_GRP_QUANTUM - max_nr_reads; struct bio *bio; /* Try to dispatch 75% READS and 25% WRITES */ @@ -1226,7 +1226,7 @@ static int throtl_select_dispatch(struct throtl_service_queue *parent_sq) if (sq->nr_queued[0] || sq->nr_queued[1]) tg_update_disptime(tg); - if (nr_disp >= throtl_quantum) + if (nr_disp >= THROTL_QUANTUM) break; } -- 1.8.3.1