Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2368617ybh; Sun, 4 Aug 2019 23:40:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYs6qhRCWwJYflzn8x8e2+MP1rM3W5amnabUzikwLu7yJ9LlA1+pHTRS6jb+9K4FkZV5Q6 X-Received: by 2002:a63:704:: with SMTP id 4mr19348642pgh.242.1564987246709; Sun, 04 Aug 2019 23:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564987246; cv=none; d=google.com; s=arc-20160816; b=efOBo/dNGMwQvOmAXUuxNeIbR9trDVRgfI3qi/J85RbxDoLN0KayTuPbeFYDuIRHSl qol1V7YWxYrRdAh+xPq0OwDUtM1DBlwJmJ6MCgZ2I+w9Zj4+ghFw95F488lCdpNd1SRd jenxzN5Kh9eOYDOCDQ28zTa3bwQMfTizmG+dUmVBI5aCqTjpld4/ncRKP+Ty5H/dg680 O7hlBEODuUZQ/3xMTtRStSTJzICCtUQURNreg7oJ5B5/hmbN2EIl1PQqLk4//K7l+sS7 4ciswD/Fk2BD8QVfke62tlB2Ip+VaDL56vh5SCB8Rw06ZX9GrRwf9dckQCGER5eSH+gF D3WQ== 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:message-id:date :subject:cc:to:from:dkim-signature; bh=CBE2RxQAGoG3LaBnrWD40VvQ1s3Zc1p2YNjhDaVQZYE=; b=FSe6CgKSTvI2Soh12YTTOqh0lyjPZOhDJ8+5dqTAyMx7MS76ZLYK30vPPZHseoESFs TAp0FSlcZMTDRrE2xtPI+cFKvRnvqnOz35rfQugPfW8LtZ950Mv3AbI/XepfhzA/lvIY ecm72W692gszbvrjckik9G31kIygvgDv3vp0ruPdnhXSyvOT+80iotjlcxaxt4Ai+jse 6UHT6MEFLj2UnGFITSbsX6GVmJrooaMrxhc2txQQlDnw6jXE79yQNOEwxjNFQOtB3kWV qoPplNWELxebPTSZVIH8zalox42IQyjIrjY0BKaSO+7wSUJrej54C+lW6CC7x/1beX+f VVUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=wIkzzujg; 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=fail (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 f12si39194887plr.211.2019.08.04.23.40.31; Sun, 04 Aug 2019 23:40:46 -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.20150623.gappssmtp.com header.s=20150623 header.b=wIkzzujg; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727476AbfHEGiU (ORCPT + 99 others); Mon, 5 Aug 2019 02:38:20 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46238 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727460AbfHEGiT (ORCPT ); Mon, 5 Aug 2019 02:38:19 -0400 Received: by mail-pf1-f194.google.com with SMTP id c3so15964507pfa.13 for ; Sun, 04 Aug 2019 23:38:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CBE2RxQAGoG3LaBnrWD40VvQ1s3Zc1p2YNjhDaVQZYE=; b=wIkzzujgXkOVi7Ki0cOf1lHqXj2TsWK0iWppP0cX5E3NgPSgD8LmlqqnGfCdKrmOiW YC/5558MPEGyzGrLSZ/odKYU7SfqvwQFsv0QK1xirJeTtwA3ZmCKproGKzoWSM7MgYoL K0npL84yKbwslvnXFud6giJKc+gi9NEoBx2fNCqY4fj2B7BUGQzEQSU/hIUcR/xVX/uP w0ezOuEvrOWAUqFBppcVxdk1fgWYqqXd6Z80d6FzzQ7Spsk5x8FZuRUW4cSlYw2ZVyi7 FT9nGH7wXkDm+naORN+RByCHNchfJqSW62DZyHPvHzUR7FFNS+zpMBdGpmE5rm6xB8Pk 74DQ== 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=CBE2RxQAGoG3LaBnrWD40VvQ1s3Zc1p2YNjhDaVQZYE=; b=h2I/Gce3cWcdpBeEzOcP5lfwpqz0Hu/Ev5yvgQCuJIyY4KUbkgasr46uDamwRKR0Qd kmq1XRNCsZ2E9TZwoqE5qUrGKkDTuMYQDqYG0MKZYKfmAi0t3F8CU1dqLd9wy8Q8jGii hhXZa/IK7/GtC12F8PFcykIXlt5ZFcJlvxjL0rlhYK29pUuJ8FXEeIvXopgARqFQTcN+ wBpdd6A13GgR7npc/tFyqEjF/Z87UXO8Kgz15MEW4LSb1DZmOIKQYMgyE85o+ZpZpYUi nXIRfH7x+F5X93FCBIjT3Ld/gi7x5TnqzcQzAvanudtdU2ne2iBk0YWC2goodEVEYjvI 8uXw== X-Gm-Message-State: APjAAAXFqvOFdObtp8ADibo2jHvKo980Mm0gpLJVnWK4Ha0m4BI87ofy aNyRg8MaG4pqw6BHQ8EEB4Ip1frczri7Sw== X-Received: by 2002:a62:f250:: with SMTP id y16mr71199579pfl.50.1564987098995; Sun, 04 Aug 2019 23:38:18 -0700 (PDT) Received: from localhost ([61.120.150.70]) by smtp.gmail.com with ESMTPSA id i124sm150930671pfe.61.2019.08.04.23.38.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Aug 2019 23:38:18 -0700 (PDT) From: Fam Zheng To: linux-kernel@vger.kernel.org Cc: axboe@kernel.dk, fam@euphon.net, paolo.valente@linaro.org, duanxiongchun@bytedance.com, linux-block@vger.kernel.org, tj@kernel.org, cgroups@vger.kernel.org, zhangjiachen.jc@bytedance.com Subject: [PATCH v2 2/3] bfq: Extract bfq_group_set_weight from bfq_io_set_weight_legacy Date: Mon, 5 Aug 2019 14:38:06 +0800 Message-Id: <20190805063807.9494-3-zhengfeiran@bytedance.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190805063807.9494-1-zhengfeiran@bytedance.com> References: <20190805063807.9494-1-zhengfeiran@bytedance.com> 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 --- 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.11.0