Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp307391ybl; Tue, 27 Aug 2019 20:57:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZUGqnX/KiC959rGALYwGV0F204o3TInLJN8mcaiKyCrdyih2St+7/FILrbCt4ijp6ktjV X-Received: by 2002:a17:902:f64:: with SMTP id 91mr2268119ply.334.1566964653028; Tue, 27 Aug 2019 20:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566964653; cv=none; d=google.com; s=arc-20160816; b=lxKYoGMEtdkIOJxKObkoD70EiLQezsFRLjwH9xNCo+s+MPj9IFBpAx0qcZ1KZFi7/S XnRv9CVC2dRxcKtscL3uvcMGaBibviP80bRQqo+g4ENNheuWV0dsTJ7D8pKVZDB8C3p4 zGGWmSLZVMpi2DDoXk3vU3C6cmutH5G8P9Yrufn36Od1EACDda1oWh8BkXn9S7aRd/wr YaZj3nUfzaFm3ARxzAq7hEDQfrf6fhmLF4/u3EYHA7rOGodqvoIhygRD3glB3JIco40+ 5WwW+926rLdG9/C3jStE/PAsquy5/T5kM2QORVs5mAXI9xi54opOYyyCsBSCNobvmKSS 4KxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Spd8tWh4JGn3fBDEW8q9V28IkZ0ZVpCm4ISnu3nMaQM=; b=KGz+bjzhMEp5rYMnSW7Uk1dwOrzC62+2X5DSytpVGgaq7+nuEZRO16yg4vmnLJtWHo 46/nmGWSQtFq5w8R8fG2T2SwSHTb6ZBbaLIl7aeWS/+L4uQlO4H9DFeO3WlaIFX1tcsg dErw7ePRwTOFaqZipUswiBecEUkVbBf79P3DLOv9DAy6EAf1atFQ6PoPw2p5Y1yjUQEO UdXz2gInQBFiUAQiTNj0nXQSbJRj+6BQk+B7Wu302Uq3tXyy/BQsNSlmwnvohLrosyOg NkykN7rH7VqQ3hqBQFGTVRdEW5QCpphjKMSVzy6s//hqRuDoTHdB83sw98tChzSZDeMn ONhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=aQ2B4fFB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si882834pjb.13.2019.08.27.20.57.16; Tue, 27 Aug 2019 20:57:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=aQ2B4fFB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbfH1DzJ (ORCPT + 99 others); Tue, 27 Aug 2019 23:55:09 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33879 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbfH1DzH (ORCPT ); Tue, 27 Aug 2019 23:55:07 -0400 Received: by mail-pf1-f196.google.com with SMTP id b24so784254pfp.1 for ; Tue, 27 Aug 2019 20:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Spd8tWh4JGn3fBDEW8q9V28IkZ0ZVpCm4ISnu3nMaQM=; b=aQ2B4fFB6wrF6qbAgHFZWLIJBhdhVTA/hv4KAiq7MVYvRbBqWjbP6CrvRB/d4Ulqx1 tRKuf+FbiNADlKz00WPw49rPF4mULQpIOTB+kw/E2Y6UwD9re9KqwiCxrBa3LvPOQZxB CRFelNFwgRThHt/CP9knGc0RrVtZSieKNJrnXkTRCah08mW/Q9Najk8yXZ9lyN05ivTL 3SXFC3gQHIkTVYriMvQtHHPhHv5EmY5AmL0qwbYs99S9wjJAi8i+NqkhVRSzcgKlLbhX lhKWX4P7PqsksULwa+wWvhUYYh/yIn+RxNYVaBrtxNgLQki5OHp17zyR+AGns9sF50HT auHA== 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:mime-version:content-transfer-encoding; bh=Spd8tWh4JGn3fBDEW8q9V28IkZ0ZVpCm4ISnu3nMaQM=; b=K/t82DFRDRfW+BRswlkWFbHgXdqUZ0sKXXO5tdE8RDrcwcJJhfZZSveeua8Xv06yvx RdXs0BaNWNZU3Crv+qQdlddVMOsxUSh6JMdM26CPQWPzixkYGj8vMGojQwVMk7VK6Vbm F9ucgi3cGfNdNjdIdBu/jBXYBIJ/x8vW7zLrjQ2UJGY0uJ90kL5XVEP/vyaGgFbX4H60 bt2tbcaUxwRns9jy7SxS/3U/35ncbQeTdO1kgalPaIYhD70g+cXrd7Y/GeXQoDytgPrJ s5fdtbfSXAYxnNOeS0uX44nvT5MgeJKOve63cmIXHJGo3mYFX4WLSgh9s0I3/vPXmbzy jZMQ== X-Gm-Message-State: APjAAAWqZup7jht7+VSxDYBsbirD0MfLy4nUV6G7INi6/5NAJlIKga+L WzDZs5I7YjpuNNWeVST1fWyakk2QzVflKA== X-Received: by 2002:a65:608e:: with SMTP id t14mr1619143pgu.373.1566964506583; Tue, 27 Aug 2019 20:55:06 -0700 (PDT) Received: from localhost ([61.120.150.70]) by smtp.gmail.com with ESMTPSA id q10sm944776pfl.8.2019.08.27.20.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 20:55:06 -0700 (PDT) From: Fam Zheng To: linux-kernel@vger.kernel.org Cc: axboe@kernel.dk, paolo.valente@linaro.org, fam@euphon.net, duanxiongchun@bytedance.com, cgroups@vger.kernel.org, zhangjiachen.jc@bytedance.com, tj@kernel.org, linux-block@vger.kernel.org Subject: [PATCH v3 2/3] bfq: Extract bfq_group_set_weight from bfq_io_set_weight_legacy Date: Wed, 28 Aug 2019 11:54:52 +0800 Message-Id: <20190828035453.18129-3-zhengfeiran@bytedance.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20190828035453.18129-1-zhengfeiran@bytedance.com> References: <20190828035453.18129-1-zhengfeiran@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This function will be useful when we update weight from the soon-coming per-device interface. Signed-off-by: Fam Zheng Reviewed-by: Paolo Valente --- block/bfq-cgroup.c | 60 ++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index 0f6cd688924f..28e5a9241237 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -918,6 +918,36 @@ static int bfq_io_show_weight(struct seq_file *sf, void *v) return 0; } +static void bfq_group_set_weight(struct bfq_group *bfqg, u64 weight) +{ + /* + * Setting the prio_changed flag of the entity + * to 1 with new_weight == weight would re-set + * the value of the weight to its ioprio mapping. + * Set the flag only if necessary. + */ + if ((unsigned short)weight != bfqg->entity.new_weight) { + bfqg->entity.new_weight = (unsigned short)weight; + /* + * Make sure that the above new value has been + * stored in bfqg->entity.new_weight before + * setting the prio_changed flag. In fact, + * this flag may be read asynchronously (in + * critical sections protected by a different + * lock than that held here), and finding this + * flag set may cause the execution of the code + * for updating parameters whose value may + * depend also on bfqg->entity.new_weight (in + * __bfq_entity_update_weight_prio). + * This barrier makes sure that the new value + * of bfqg->entity.new_weight is correctly + * seen in that code. + */ + smp_wmb(); + bfqg->entity.prio_changed = 1; + } +} + static int bfq_io_set_weight_legacy(struct cgroup_subsys_state *css, struct cftype *cftype, u64 val) @@ -936,34 +966,8 @@ static int bfq_io_set_weight_legacy(struct cgroup_subsys_state *css, hlist_for_each_entry(blkg, &blkcg->blkg_list, blkcg_node) { struct bfq_group *bfqg = blkg_to_bfqg(blkg); - if (!bfqg) - continue; - /* - * Setting the prio_changed flag of the entity - * to 1 with new_weight == weight would re-set - * the value of the weight to its ioprio mapping. - * Set the flag only if necessary. - */ - if ((unsigned short)val != bfqg->entity.new_weight) { - bfqg->entity.new_weight = (unsigned short)val; - /* - * Make sure that the above new value has been - * stored in bfqg->entity.new_weight before - * setting the prio_changed flag. In fact, - * this flag may be read asynchronously (in - * critical sections protected by a different - * lock than that held here), and finding this - * flag set may cause the execution of the code - * for updating parameters whose value may - * depend also on bfqg->entity.new_weight (in - * __bfq_entity_update_weight_prio). - * This barrier makes sure that the new value - * of bfqg->entity.new_weight is correctly - * seen in that code. - */ - smp_wmb(); - bfqg->entity.prio_changed = 1; - } + if (bfqg) + bfq_group_set_weight(bfqg, val); } spin_unlock_irq(&blkcg->lock); -- 2.22.1