linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Tejun Heo <tj@kernel.org>
Cc: Jan Kara <jack@suse.cz>, Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH block/for-next] writeback: add tracepoints for cgroup foreign writebacks
Date: Fri, 30 Aug 2019 18:42:11 +0200	[thread overview]
Message-ID: <20190830164211.GD25069@quack2.suse.cz> (raw)
In-Reply-To: <20190830154921.GZ2263813@devbig004.ftw2.facebook.com>

On Fri 30-08-19 08:49:21, Tejun Heo wrote:
> Hello, Jan.
> 
> On Fri, Aug 30, 2019 at 05:40:23PM +0200, Jan Kara wrote:
> > > +	TP_fast_assign(
> > > +		strncpy(__entry->name,	dev_name(wb->bdi->dev), 32);
> > > +		__entry->bdi_id		= wb->bdi->id;
> > > +		__entry->ino		= page->mapping->host->i_ino;
> > > +		__entry->memcg_id	= wb->memcg_css->id;
> > > +		__entry->cgroup_ino	= __trace_wb_assign_cgroup(wb);
> > > +		__entry->page_cgroup_ino = page->mem_cgroup->css.cgroup->kn->id.ino;
> > > +	),
> > 
> > Are the page dereferences above safe? I suppose lock_page_memcg() protects
> > the page->mem_cgroup->css.cgroup->kn->id dereference? But page->mapping
> > does not seem to be protected by page lock?
> 
> Hah, I assumed it would work because there are preceding if
> (page_mapping()) tests in the dirty paths -
> e.g. __set_page_dirty_nobuffers().  Oh, regardless of that assumption,
> I should have used page_mapping().

Well, but if you look at __set_page_dirty_nobuffers() it is careful. It
does:

struct address_space *mapping = page_mapping(page);

if (!mapping) {
	bail
}
... use mapping

Exactly because page->mapping can become NULL under your hands if you don't
hold page lock. So I think you either need something similar in your
tracepoint or handle this in the caller.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2019-08-30 16:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-29 22:47 [PATCH block/for-next] writeback: add tracepoints for cgroup foreign writebacks Tejun Heo
2019-08-30 13:43 ` Jens Axboe
2019-08-30 15:40 ` Jan Kara
2019-08-30 15:49   ` Tejun Heo
2019-08-30 16:42     ` Jan Kara [this message]
2019-08-30 17:09       ` Tejun Heo
2019-09-02  8:38         ` Jan Kara
2019-08-30 15:51   ` Tejun Heo

Reply instructions:

You may reply publicly 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=20190830164211.GD25069@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).