Linux-Block Archive on lore.kernel.org
 help / color / Atom feed
From: Jan Kara <jack@suse.cz>
To: Tejun Heo <tj@kernel.org>
Cc: axboe@kernel.dk, jack@suse.cz, hannes@cmpxchg.org,
	mhocko@kernel.org, vdavydov.dev@gmail.com,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@fb.com, guro@fb.com, akpm@linux-foundation.org
Subject: Re: [PATCH 3/5] writeback: Separate out wb_get_lookup() from wb_get_create()
Date: Fri, 16 Aug 2019 17:45:37 +0200
Message-ID: <20190816154537.GG3041@quack2.suse.cz> (raw)
In-Reply-To: <20190815195823.GD2263813@devbig004.ftw2.facebook.com>

On Thu 15-08-19 12:58:23, Tejun Heo wrote:
> Separate out wb_get_lookup() which doesn't try to create one if there
> isn't already one from wb_get_create().  This will be used by later
> patches.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>

Looks good to me. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  include/linux/backing-dev.h |    2 +
>  mm/backing-dev.c            |   55 +++++++++++++++++++++++++++++---------------
>  2 files changed, 39 insertions(+), 18 deletions(-)
> 
> --- a/include/linux/backing-dev.h
> +++ b/include/linux/backing-dev.h
> @@ -230,6 +230,8 @@ static inline int bdi_sched_wait(void *w
>  struct bdi_writeback_congested *
>  wb_congested_get_create(struct backing_dev_info *bdi, int blkcg_id, gfp_t gfp);
>  void wb_congested_put(struct bdi_writeback_congested *congested);
> +struct bdi_writeback *wb_get_lookup(struct backing_dev_info *bdi,
> +				    struct cgroup_subsys_state *memcg_css);
>  struct bdi_writeback *wb_get_create(struct backing_dev_info *bdi,
>  				    struct cgroup_subsys_state *memcg_css,
>  				    gfp_t gfp);
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -618,13 +618,12 @@ out_put:
>  }
>  
>  /**
> - * wb_get_create - get wb for a given memcg, create if necessary
> + * wb_get_lookup - get wb for a given memcg
>   * @bdi: target bdi
>   * @memcg_css: cgroup_subsys_state of the target memcg (must have positive ref)
> - * @gfp: allocation mask to use
>   *
> - * Try to get the wb for @memcg_css on @bdi.  If it doesn't exist, try to
> - * create one.  The returned wb has its refcount incremented.
> + * Try to get the wb for @memcg_css on @bdi.  The returned wb has its
> + * refcount incremented.
>   *
>   * This function uses css_get() on @memcg_css and thus expects its refcnt
>   * to be positive on invocation.  IOW, rcu_read_lock() protection on
> @@ -641,6 +640,39 @@ out_put:
>   * each lookup.  On mismatch, the existing wb is discarded and a new one is
>   * created.
>   */
> +struct bdi_writeback *wb_get_lookup(struct backing_dev_info *bdi,
> +				    struct cgroup_subsys_state *memcg_css)
> +{
> +	struct bdi_writeback *wb;
> +
> +	if (!memcg_css->parent)
> +		return &bdi->wb;
> +
> +	rcu_read_lock();
> +	wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id);
> +	if (wb) {
> +		struct cgroup_subsys_state *blkcg_css;
> +
> +		/* see whether the blkcg association has changed */
> +		blkcg_css = cgroup_get_e_css(memcg_css->cgroup, &io_cgrp_subsys);
> +		if (unlikely(wb->blkcg_css != blkcg_css || !wb_tryget(wb)))
> +			wb = NULL;
> +		css_put(blkcg_css);
> +	}
> +	rcu_read_unlock();
> +
> +	return wb;
> +}
> +
> +/**
> + * wb_get_create - get wb for a given memcg, create if necessary
> + * @bdi: target bdi
> + * @memcg_css: cgroup_subsys_state of the target memcg (must have positive ref)
> + * @gfp: allocation mask to use
> + *
> + * Try to get the wb for @memcg_css on @bdi.  If it doesn't exist, try to
> + * create one.  See wb_get_lookup() for more details.
> + */
>  struct bdi_writeback *wb_get_create(struct backing_dev_info *bdi,
>  				    struct cgroup_subsys_state *memcg_css,
>  				    gfp_t gfp)
> @@ -653,20 +685,7 @@ struct bdi_writeback *wb_get_create(stru
>  		return &bdi->wb;
>  
>  	do {
> -		rcu_read_lock();
> -		wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id);
> -		if (wb) {
> -			struct cgroup_subsys_state *blkcg_css;
> -
> -			/* see whether the blkcg association has changed */
> -			blkcg_css = cgroup_get_e_css(memcg_css->cgroup,
> -						     &io_cgrp_subsys);
> -			if (unlikely(wb->blkcg_css != blkcg_css ||
> -				     !wb_tryget(wb)))
> -				wb = NULL;
> -			css_put(blkcg_css);
> -		}
> -		rcu_read_unlock();
> +		wb = wb_get_lookup(bdi, memcg_css);
>  	} while (!wb && !cgwb_create(bdi, memcg_css, gfp));
>  
>  	return wb;
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply index

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-15 19:56 [PATCHSET v2] writeback, memcg: Implement foreign inode flushing Tejun Heo
2019-08-15 19:57 ` [PATCH 1/5] writeback: Generalize and expose wb_completion Tejun Heo
2019-08-15 19:57 ` [PATCH 2/5] bdi: Add bdi->id Tejun Heo
2019-08-15 19:58 ` [PATCH 3/5] writeback: Separate out wb_get_lookup() from wb_get_create() Tejun Heo
2019-08-16 15:45   ` Jan Kara [this message]
2019-08-15 19:59 ` [PATCH 4/5] writeback, memcg: Implement cgroup_writeback_by_id() Tejun Heo
2019-08-16 15:47   ` Jan Kara
2019-08-21 21:02   ` [PATCH v3 " Tejun Heo
2019-08-26 13:49     ` Jan Kara
2019-08-15 19:59 ` [PATCH 5/5] writeback, memcg: Implement foreign dirty flushing Tejun Heo
2019-08-16 16:02   ` Jan Kara
2019-08-21 16:00     ` Tejun Heo
2019-08-21 16:04       ` Tejun Heo
2019-08-21 21:02   ` [PATCH v3 " Tejun Heo
2019-08-26 13:54     ` Jan Kara
2019-08-26 15:58       ` Tejun Heo
2019-08-26 16:06 [PATCHSET v3] writeback, memcg: Implement foreign inode flushing Tejun Heo
2019-08-26 16:06 ` [PATCH 3/5] writeback: Separate out wb_get_lookup() from wb_get_create() Tejun Heo

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190816154537.GG3041@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=guro@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=tj@kernel.org \
    --cc=vdavydov.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org linux-block@archiver.kernel.org
	public-inbox-index linux-block


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/ public-inbox