Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp345950pxj; Thu, 10 Jun 2021 02:07:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaH0FBlF1rJ5wcozBu+5LT3Hue34HTPvkfBgr5gzM4bHARs/GX5OeEGHGK8qjFVlGFTKr1 X-Received: by 2002:a17:906:9512:: with SMTP id u18mr3555887ejx.61.1623316052113; Thu, 10 Jun 2021 02:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623316052; cv=none; d=google.com; s=arc-20160816; b=C+IW/YtLMb3OfzyFAy9ys0TFCho/UWVYhiRlyAHFRlOcuMxQLHA0Fum8WTTjhwEWUI SHU7axgwUr/CAT0LBJDzx54Uorv2i4JaugQm6D4CHSLCYlXAX3SrcFuu93DclMVMU8p1 2AKM0iubVBB+3HUvhy7z9iq1RepLEGJka7aDWuOafh391UM8U7thMk8vWnnl6MvH70yu PjnDqknVYl9cEGBJBqvpNIUXq0qZYJsewXxip+aPXp9WeSceb1smrxTAXz5tDMXsQObl kcu+AKtuiCkjk0ifzD/hUTjmLTg4EjjLFhGELk+FeQf0LR1LrCf19uZ5m3Kfn/dVRHlQ SU3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=WVYZh37iLNE3J4xzwZTUdF1tvtQC8S/ydWacg9ipzgY=; b=jdg/SOaKVxSsGSZEmlQpXZ0ypyinAO4W80z2t+BUtatyvy8BPf3TnnVnAtqsSNGfE7 oL1dH6vf+5RCIkL4MT2DpTdOZRTGtnvUKAnDnpTlnAc0chqDDakVFyg9UdgT5hOb6Iu7 xoM2jQRK18K1xuDz/qNTqGFcVYOZ7RzsxPVQSQV1DerMZq3t7yoBSlIrgXYQPjGAyis8 gk5qG0iBlMjK8WMeK/q0UTJ8hw10jCKKsGJIo2Ii6/yayiR3Wua8RuOs5yB5VmZ0mL2T qRIUJje1M5XbnEhDLyv1kMo2esIMaeXJ2CQIoZswtXJi2yZ869E6PnxbkYeZpeMCi3RY 2lMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KdpAAEnO; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ba29si1708719edb.601.2021.06.10.02.07.07; Thu, 10 Jun 2021 02:07:32 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KdpAAEnO; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230166AbhFJJIK (ORCPT + 99 others); Thu, 10 Jun 2021 05:08:10 -0400 Received: from mail-pg1-f172.google.com ([209.85.215.172]:43679 "EHLO mail-pg1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbhFJJIJ (ORCPT ); Thu, 10 Jun 2021 05:08:09 -0400 Received: by mail-pg1-f172.google.com with SMTP id e22so22044360pgv.10; Thu, 10 Jun 2021 02:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=WVYZh37iLNE3J4xzwZTUdF1tvtQC8S/ydWacg9ipzgY=; b=KdpAAEnO2Z2FCmbpRQ/ye4dryVfTV8KCyXdcKGPCEoWI0PEyPkZ2qof3wxuDvUHP91 aWFO/y9owh7OoKAdy64N22ZRZquRGuyZdh6Cq1n6v36bCiN1Y2+nMxLeiVYmmAxYZvVN 8GgrQ32n9oB2gj5RQxhFJGSbJG8iq9FEA2oEL+KlEe1Bd9Tp/PQVlPOch7t7CT9CB1+9 iJ8sWwxS2gEOcy7RyBoyiY5eiqvaKMwYXlqPpl66u0nPMchObxwZAPkZGPlscitzEMRN SYN9DNI20X7Aj1V0u+v/gyzGb5CfAM38ChBCnH/oiMVdTYvYcL5jnvuJdbqyG+/T/Lbg Naig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WVYZh37iLNE3J4xzwZTUdF1tvtQC8S/ydWacg9ipzgY=; b=IAYpe8Zu/JE8jc3TxOWIuaCXVEwRHMO8GroO11VVbIXPsebomR81oIH61aTesbOZ0w Qig56TTJD1v6vdOhBdVNttIJVYlnXIwbH15hlk7YlhkOKu+NKJwxtXEpxH9bPOj+vbD8 +vEQ3lAxGO/qQofaVIxgF5sGLOGT/LABL0DS2Jr92Cvvqqn1FNYn8qCl9ZZiUUAKEb1K P+ChSW0P7vJTntmqVW05o1UtQn/o+d1oJxis58pY0D0h3UURUr6TuW1X9Ov4reGuVz+g Ch/5wfLhMvdbRdkcuW61Tij5shaaVGgApXVtcdrmFYP6BrYluaCvLF763hWXyyfCQfNz G1EQ== X-Gm-Message-State: AOAM531BCY0lmWI9MxVJrLCBX3HTw6JdY+CQEp0jk6qokiZnRMoH5Ykh rM1tcLNoj1OkzOPlZiHmc+E= X-Received: by 2002:aa7:8641:0:b029:2f4:7263:5524 with SMTP id a1-20020aa786410000b02902f472635524mr2083010pfo.70.1623315913522; Thu, 10 Jun 2021 02:05:13 -0700 (PDT) Received: from [127.0.0.1] ([203.205.141.39]) by smtp.gmail.com with ESMTPSA id u9sm2084786pgp.90.2021.06.10.02.05.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Jun 2021 02:05:13 -0700 (PDT) Subject: Re: [RESEND PATCH 1/8] bfq: introduce bfq_entity_to_bfqg helper method To: Oleksandr Natalenko Cc: paolo.valente@linaro.org, axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Piotr Gorski References: <20210610072230.TAxxdh-wsL4sihK2TJxF-Gz85ZgsFR7IwOuifnxFi0k@z> <20210610083147.xoefokucl5ey7v32@spock.localdomain> From: brookxu Message-ID: Date: Thu, 10 Jun 2021 17:05:05 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210610083147.xoefokucl5ey7v32@spock.localdomain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oleksandr Natalenko wrote on 2021/6/10 16:31: > Hello. > > On Thu, Jun 10, 2021 at 03:22:30PM +0800, brookxu wrote: >> From: Chunguang Xu >> >> Introduce bfq_entity_to_bfqg() to make it easier to obtain the >> bfq_group corresponding to the entity. >> >> Signed-off-by: Chunguang Xu >> --- >> block/bfq-cgroup.c | 6 ++---- >> block/bfq-iosched.h | 1 + >> block/bfq-wf2q.c | 16 ++++++++++++---- >> 3 files changed, 15 insertions(+), 8 deletions(-) >> >> diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c >> index b791e20..a5f544a 100644 >> --- a/block/bfq-cgroup.c >> +++ b/block/bfq-cgroup.c >> @@ -309,8 +309,7 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq) >> { >> struct bfq_entity *group_entity = bfqq->entity.parent; >> >> - return group_entity ? container_of(group_entity, struct bfq_group, >> - entity) : >> + return group_entity ? bfq_entity_to_bfqg(group_entity) : >> bfqq->bfqd->root_group; >> } >> >> @@ -610,8 +609,7 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd, >> */ >> entity = &bfqg->entity; >> for_each_entity(entity) { >> - struct bfq_group *curr_bfqg = container_of(entity, >> - struct bfq_group, entity); >> + struct bfq_group *curr_bfqg = bfq_entity_to_bfqg(entity); >> if (curr_bfqg != bfqd->root_group) { >> parent = bfqg_parent(curr_bfqg); >> if (!parent) >> diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h >> index b8e793c..a6f98e9 100644 >> --- a/block/bfq-iosched.h >> +++ b/block/bfq-iosched.h >> @@ -941,6 +941,7 @@ struct bfq_group { >> #endif >> >> struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity); >> +struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity); >> >> /* --------------- main algorithm interface ----------------- */ >> >> diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c >> index 070e34a..5ff0028 100644 >> --- a/block/bfq-wf2q.c >> +++ b/block/bfq-wf2q.c >> @@ -149,7 +149,7 @@ struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq) >> if (!group_entity) >> group_entity = &bfqq->bfqd->root_group->entity; >> >> - return container_of(group_entity, struct bfq_group, entity); >> + return bfq_entity_to_bfqg(group_entity); >> } >> >> /* >> @@ -208,7 +208,7 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity) >> if (bfq_entity_to_bfqq(entity)) >> return true; >> >> - bfqg = container_of(entity, struct bfq_group, entity); >> + bfqg = bfq_entity_to_bfqg(entity); >> >> /* >> * The field active_entities does not always contain the >> @@ -266,6 +266,15 @@ struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity) >> return bfqq; >> } >> >> +struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity) >> +{ >> + struct bfq_group *bfqg = NULL; >> + >> + if (entity->my_sched_data) >> + bfqg = container_of(entity, struct bfq_group, entity); >> + >> + return bfqg; >> +} >> >> /** >> * bfq_delta - map service into the virtual time domain. >> @@ -1001,8 +1010,7 @@ static void __bfq_activate_entity(struct bfq_entity *entity, >> >> #ifdef CONFIG_BFQ_GROUP_IOSCHED >> if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */ >> - struct bfq_group *bfqg = >> - container_of(entity, struct bfq_group, entity); >> + struct bfq_group *bfqg = bfq_entity_to_bfqg(entity); >> struct bfq_data *bfqd = bfqg->bfqd; >> >> if (!entity->in_groups_with_pending_reqs) { >> -- >> 1.8.3.1 >> > > If it is a resend only, I can offer my Tested-by since I'm running this > series for quite some time already. > ok, thank you very much. > Thanks. >