Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp459102imu; Mon, 26 Nov 2018 13:21:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/U3RVHkr9kvXdUGT4rr0DSY8jRNCYiD5R6ETYSAOnNMhGJhT4lZIvU4Pvfb5633qI10PgTn X-Received: by 2002:a17:902:a70b:: with SMTP id w11mr29194878plq.84.1543267279700; Mon, 26 Nov 2018 13:21:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543267279; cv=none; d=google.com; s=arc-20160816; b=B5ltYAkb1XBoJlXK47myeB+PT3bWWsTYpjFju2Ii22y0odNpVpXQVK/M90DlSQ9dHk 5rtnMiyJ5df0mmfNj5YZrBQQP8KxmHr4jI3+NTwrMa7GyHNAGg8xidhYkRtJWjsQSRAM MLoKMKDYRRUWvaXr1j7Km9SOJjXNYhClQSTE6FUix6uEVGOaVxhfTAGIxdcEVzYbarfL RHeR5YHt7o+PPCOaryCGC+f3HRHlcAnOFrQzFTvqbTsWU1vJLmtRE3Ygz8TPb3lg1hi2 0dUP4ATjtLJ5gylETDYrRMqddlDv1M+nPf5pSOIeNVfuD0dGldTIZViLopKNT2xqWksb qnvA== 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; bh=kDWB6v2Sjdd1SXjPBLbMJlV6MI6UKkWJSLdUCbEjuHM=; b=pKZvLEn1v0lWVKD0rdMFeWD4t4OSV9WNXghEetdZ82UbZeey8xUuDxDi9Un5ONWLWH bQiI51CKlS27I24K+fEHEjtTvnqkjZl2HTAQFJVAkxbhrIX99VKa5EfWIDO5FcBnPTqu fPhcACHCJzgDecy5ZvE3pV01tYYmbjvkNj6me/VVCxifQYinnRJ33H3HFOfddlSVLR0l glOtjRhQvVvp0x4TpjRhfguFaijCPVMR7uCSldKypehg7pOVuETFchKGIuf2Vu4JfH/M bJeZOTQSci5YsxevDUCysIzwRCFn0w3D8Tg/IWB8IxALYl/1CmUrpGz9LksNttfjDPKn cCyQ== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9si1436280plb.35.2018.11.26.13.21.04; Mon, 26 Nov 2018 13:21:19 -0800 (PST) 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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727586AbeK0IPh (ORCPT + 99 others); Tue, 27 Nov 2018 03:15:37 -0500 Received: from mail-yb1-f196.google.com ([209.85.219.196]:44734 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727551AbeK0IPf (ORCPT ); Tue, 27 Nov 2018 03:15:35 -0500 Received: by mail-yb1-f196.google.com with SMTP id p144-v6so8120911yba.11; Mon, 26 Nov 2018 13:20:09 -0800 (PST) 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=kDWB6v2Sjdd1SXjPBLbMJlV6MI6UKkWJSLdUCbEjuHM=; b=a5sxn+OQmV+h/u1U/qUn7QZRVa47uE/Jxc8jiDEfPYmwiJpCM1NylYUOeafF4mPLxe 0rldvYHed0ZLOrFEWWvaayD/74scUH2oeGUj9vi6ZU1uq4HHCHFrx3TtC47870bUZqEm P2E35dNMIELL/yMKhWxq07ayNwPj7gaQfJBlndP2PfMLu0NcOKOCaffOMkseS2thVqJk jIq88sNKoDPajf2ilew7nV66yPAnRZ2dgFFScXq5a5tXIMmGxbnCimqfSrNG5nWlXkhr /F/VXJc9xrrTjA0qQ6s7bMEyZ4sv2avCxWfg2cd7EmLRZ0rjTKO7A6bHDGwxlIwsDrt3 jLOw== X-Gm-Message-State: AA+aEWa6Ct/TWdzwRWD8vKEFdensr8KIQca2AwU0hJVyYJjdxWa79ijT lqz6IYf0PB20amy4Hi06x30= X-Received: by 2002:a25:97c4:: with SMTP id j4-v6mr24280278ybo.448.1543267208906; Mon, 26 Nov 2018 13:20:08 -0800 (PST) Received: from dennisz-mbp.thefacebook.com ([199.201.65.135]) by smtp.gmail.com with ESMTPSA id d135-v6sm495462ywh.43.2018.11.26.13.20.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Nov 2018 13:20:08 -0800 (PST) From: Dennis Zhou To: Jens Axboe , Tejun Heo , Johannes Weiner , Josef Bacik Cc: kernel-team@fb.com, linux-block@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Dennis Zhou Subject: [PATCH 13/13] blkcg: rename blkg_try_get() to blkg_tryget() Date: Mon, 26 Nov 2018 16:19:46 -0500 Message-Id: <20181126211946.77067-14-dennis@kernel.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20181126211946.77067-1-dennis@kernel.org> References: <20181126211946.77067-1-dennis@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org blkg reference counting now uses percpu_ref rather than atomic_t. Let's make this consistent with css_tryget. This renames blkg_try_get to blkg_tryget and now returns a bool rather than the blkg or %NULL. Signed-off-by: Dennis Zhou Reviewed-by: Josef Bacik Acked-by: Tejun Heo --- block/bio.c | 2 +- block/blk-cgroup.c | 3 +-- block/blk-iolatency.c | 2 +- include/linux/blk-cgroup.h | 12 +++++------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/block/bio.c b/block/bio.c index 41cc2ead39f5..434a55bc310e 100644 --- a/block/bio.c +++ b/block/bio.c @@ -2004,7 +2004,7 @@ static void __bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg) if (bio->bi_blkg) bio_disassociate_blkg(bio); - bio->bi_blkg = blkg_try_get_closest(blkg); + bio->bi_blkg = blkg_tryget_closest(blkg); } /** diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 64ce424a78fd..8fc588754861 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1738,8 +1738,7 @@ void blkcg_maybe_throttle_current(void) blkg = blkg_lookup(blkcg, q); if (!blkg) goto out; - blkg = blkg_try_get(blkg); - if (!blkg) + if (!blkg_tryget(blkg)) goto out; rcu_read_unlock(); diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 5a79f06a730d..0b14c3d57769 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -698,7 +698,7 @@ static void blkiolatency_timer_fn(struct timer_list *t) * We could be exiting, don't access the pd unless we have a * ref on the blkg. */ - if (!blkg_try_get(blkg)) + if (!blkg_tryget(blkg)) continue; iolat = blkg_to_lat(blkg); diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index fc23bb758566..3741f5b78ffd 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -490,27 +490,25 @@ static inline void blkg_get(struct blkcg_gq *blkg) } /** - * blkg_try_get - try and get a blkg reference + * blkg_tryget - try and get a blkg reference * @blkg: blkg to get * * This is for use when doing an RCU lookup of the blkg. We may be in the midst * of freeing this blkg, so we can only use it if the refcnt is not zero. */ -static inline struct blkcg_gq *blkg_try_get(struct blkcg_gq *blkg) +static inline bool blkg_tryget(struct blkcg_gq *blkg) { - if (percpu_ref_tryget(&blkg->refcnt)) - return blkg; - return NULL; + return percpu_ref_tryget(&blkg->refcnt); } /** - * blkg_try_get_closest - try and get a blkg ref on the closet blkg + * blkg_tryget_closest - try and get a blkg ref on the closet blkg * @blkg: blkg to get * * This walks up the blkg tree to find the closest non-dying blkg and returns * the blkg that it did association with as it may not be the passed in blkg. */ -static inline struct blkcg_gq *blkg_try_get_closest(struct blkcg_gq *blkg) +static inline struct blkcg_gq *blkg_tryget_closest(struct blkcg_gq *blkg) { while (!percpu_ref_tryget(&blkg->refcnt)) blkg = blkg->parent; -- 2.17.1