Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4426782imm; Tue, 11 Sep 2018 11:42:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYOfuFoCux1dZwtgRjFeMnFIw1xbniTfbOCtORqEBikUf2DDizAa/lr8CHdz5UnV7FwjGMk X-Received: by 2002:a17:902:6907:: with SMTP id j7-v6mr28738314plk.323.1536691360300; Tue, 11 Sep 2018 11:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536691360; cv=none; d=google.com; s=arc-20160816; b=R5w38xPdjP1CpuAkQsK6mLXlg5pGc8TVDuQn/y16EWWwOJqbSJb7W+C19kNUq77Olf UmUV69nuBwlLcXamwOoTVqR5dvazzvDkkxYejqZ7E1l1IBN6orxiWvYiwqAZC26EsXiN 3pJPn5xTt44hPFXdi6d+tHL+GtoDc+IQFR9rYWle/kH3fXRaF2aLXhWOR/ty540EDW0X pyI8P+955OPX1HOY7OLpMDfe3sfKmTYq84xfY8Yz3UXrtiyjI8fkGHXYHFy+M4DAZW11 HxEQGhCBjB740qDeRzV5Hafhjnc3lMIQt0RZLhAheXkNSvJ0jqx1T1S9fEj7ua3rzdfU dtpw== 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=zhl/2Dyq9QvCeiNHqKLR3IjW7/h51nLcSK+lBauCWR0=; b=eL/KobDa6YHJ7rRuB8TncuLru6b6AXXday/PD8TYt8gbAAjurE12Fo6wiIkaJkgFnA IEvrKIwu1lWyNRP8ktT4HgyXc2O3qEQVMN3ec+XU0Wn6dyYiQJ16QpDG+Y0zdqndPNYc N+ED2U+dti9N5J6KT2/IjMSb50PHh+RZOhaHbyPqylh6M+0WFAHb7PbOOlhOB3nwR9EL dSJ/WnjGVSE0wpXsKqwc0hbJjOOe7ZWY4HPGeiRP31wcmNzO9+8hnR0SxYlKeMaLNOUH jPknrmPLaY2pLV7xw51tc6eisj4+UU+SvIM8vh4BDSis6BnKqDXo0DHcr7qombRrvY/I 9olg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gdwOfXpU; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 85-v6si21951926pgh.381.2018.09.11.11.42.25; Tue, 11 Sep 2018 11:42:40 -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=@gmail.com header.s=20161025 header.b=gdwOfXpU; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728428AbeIKXmo (ORCPT + 99 others); Tue, 11 Sep 2018 19:42:44 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:47093 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728368AbeIKXmd (ORCPT ); Tue, 11 Sep 2018 19:42:33 -0400 Received: by mail-yw1-f68.google.com with SMTP id j131-v6so9596783ywc.13; Tue, 11 Sep 2018 11:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zhl/2Dyq9QvCeiNHqKLR3IjW7/h51nLcSK+lBauCWR0=; b=gdwOfXpUVXotNnENEC5Plz4ZaeFlcFnbenVx5eLjQXQUnNbYlwV7N8Qpyz6GpF8h56 /s1+KnWao0oPn02D0hq7deBhx2teTphXM4eOl/c0JEmcrZCl2ZV/fycMaEdZjQSWTkqW Gh2iRQvB6ez/gkVNU+TtgbjPuT9bPXjwkz5+PNQiZ4Q+z5sjfEGjbLX2+McLy3whXxWH l0dauewPyU+OcbMxjdL3acVpVhXqVrij9B5gHzEHa1EmLzEYRRfBcDUGmX2fteDAJfb9 YkEXu+/WRZcLPCZ8B7cjwMiIQhem4MKSR4jGmNmDbEiWRLafPk6vysEsHCroD6QMgKhz oAmA== 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=zhl/2Dyq9QvCeiNHqKLR3IjW7/h51nLcSK+lBauCWR0=; b=PMuq/SZGaHkkT9m9R+wUBriH2dMNx1TjfXG9R9+46WDG05M2dcj7fTsbqNrRDrgUru QbFhhXbTKuXF1Op6X1/YEBnZWwOA6cc0O9XS+qR/5Xn6Ux2az53GzWOrAWizkxIXpILv benQD8JZ1EZg+rvXszP4pSDT8T8A1JGfcAkIec/RY2ko5Fje0L8jWgqgUyls0mROchjw u0wUrlL1AowU+k802uf4cfvx44Qcqvwn9puznTdDLMe2GVbbW/4+sqPTEvCB82/ixkLE oEnOwfpJ5WiL63W2Jmmd4BXCOONydH0RIXxIQXisyUVnny0wxtu3Msq3gU/CdhOaj1ZI 1Ciw== X-Gm-Message-State: APzg51AwxUOsajgBpecDq2yr08gFehAYDuiDW9j40SnEEDQ9KosYU4VI k/lNKqm/F8tWQigEAmfyNKA= X-Received: by 2002:a81:812:: with SMTP id 18-v6mr13280788ywi.475.1536691317739; Tue, 11 Sep 2018 11:41:57 -0700 (PDT) Received: from dennisz-mbp.thefacebook.com ([199.201.65.129]) by smtp.gmail.com with ESMTPSA id i123-v6sm7902875ywe.14.2018.09.11.11.41.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 11:41:57 -0700 (PDT) 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 (Facebook)" Subject: [PATCH 12/12] blkcg: rename blkg_try_get to blkg_tryget Date: Tue, 11 Sep 2018 14:41:37 -0400 Message-Id: <20180911184137.35897-13-dennisszhou@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180911184137.35897-1-dennisszhou@gmail.com> References: <20180911184137.35897-1-dennisszhou@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Dennis Zhou (Facebook)" 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 | 14 ++++++-------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/block/bio.c b/block/bio.c index a65ab3bacb4f..14351fac07cd 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1975,7 +1975,7 @@ int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg) { if (unlikely(bio->bi_blkg)) return -EBUSY; - bio->bi_blkg = blkg_try_get_closest(blkg); + bio->bi_blkg = blkg_tryget_closest(blkg); return 0; } diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index ab3676e1e15e..76136bea7a7f 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1794,8 +1794,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 9d7052bad6f7..5a4cec54c998 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -628,7 +628,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 7ff5d8ba8c7a..b7fd08013de2 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -494,27 +494,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; @@ -599,7 +597,7 @@ static inline struct request_list *blk_get_rl(struct request_queue *q, if (unlikely(!blkg)) blkg = __blkg_lookup_create(blkcg, q); - if (!blkg_try_get(blkg)) + if (!blkg_tryget(blkg)) goto rl_use_root; rcu_read_unlock(); -- 2.17.1