* [block/for-next] writeback: don't access page->mapping directly in track_foreign_dirty TP
@ 2019-08-30 23:39 Tejun Heo
2019-08-31 1:54 ` Jens Axboe
2019-09-02 8:56 ` Jan Kara
0 siblings, 2 replies; 3+ messages in thread
From: Tejun Heo @ 2019-08-30 23:39 UTC (permalink / raw)
To: Jens Axboe, Jan Kara; +Cc: linux-block, linux-kernel, kernel-team
page->mapping may encode different values in it and page_mapping()
should always be used to access the mapping pointer.
track_foreign_dirty tracepoint was incorrectly accessing page->mapping
directly. Use page_mapping() instead. Also, add NULL checks while at
it.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Jan Kara <jack@suse.cz>
Fixes: 3a8e9ac89e6a ("writeback: add tracepoints for cgroup foreign writebacks")
---
include/trace/events/writeback.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 3dc9fb9e7c78..3a27335fce2c 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -251,9 +251,12 @@ TRACE_EVENT(track_foreign_dirty,
),
TP_fast_assign(
+ struct address_space *mapping = page_mapping(page);
+ struct inode *inode = mapping ? mapping->host : NULL;
+
strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
__entry->bdi_id = wb->bdi->id;
- __entry->ino = page->mapping->host->i_ino;
+ __entry->ino = inode ? inode->i_ino : 0;
__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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [block/for-next] writeback: don't access page->mapping directly in track_foreign_dirty TP
2019-08-30 23:39 [block/for-next] writeback: don't access page->mapping directly in track_foreign_dirty TP Tejun Heo
@ 2019-08-31 1:54 ` Jens Axboe
2019-09-02 8:56 ` Jan Kara
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2019-08-31 1:54 UTC (permalink / raw)
To: Tejun Heo, Jan Kara; +Cc: linux-block, linux-kernel, kernel-team
On 8/30/19 5:39 PM, Tejun Heo wrote:
> page->mapping may encode different values in it and page_mapping()
> should always be used to access the mapping pointer.
> track_foreign_dirty tracepoint was incorrectly accessing page->mapping
> directly. Use page_mapping() instead. Also, add NULL checks while at
> it.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [block/for-next] writeback: don't access page->mapping directly in track_foreign_dirty TP
2019-08-30 23:39 [block/for-next] writeback: don't access page->mapping directly in track_foreign_dirty TP Tejun Heo
2019-08-31 1:54 ` Jens Axboe
@ 2019-09-02 8:56 ` Jan Kara
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2019-09-02 8:56 UTC (permalink / raw)
To: Tejun Heo; +Cc: Jens Axboe, Jan Kara, linux-block, linux-kernel, kernel-team
On Fri 30-08-19 16:39:54, Tejun Heo wrote:
> page->mapping may encode different values in it and page_mapping()
> should always be used to access the mapping pointer.
> track_foreign_dirty tracepoint was incorrectly accessing page->mapping
> directly. Use page_mapping() instead. Also, add NULL checks while at
> it.
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Reported-by: Jan Kara <jack@suse.cz>
> Fixes: 3a8e9ac89e6a ("writeback: add tracepoints for cgroup foreign writebacks")
I can see Jens already picked this up so this is just informative: The patch
now looks good to me.
Honza
> ---
> include/trace/events/writeback.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
> index 3dc9fb9e7c78..3a27335fce2c 100644
> --- a/include/trace/events/writeback.h
> +++ b/include/trace/events/writeback.h
> @@ -251,9 +251,12 @@ TRACE_EVENT(track_foreign_dirty,
> ),
>
> TP_fast_assign(
> + struct address_space *mapping = page_mapping(page);
> + struct inode *inode = mapping ? mapping->host : NULL;
> +
> strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
> __entry->bdi_id = wb->bdi->id;
> - __entry->ino = page->mapping->host->i_ino;
> + __entry->ino = inode ? inode->i_ino : 0;
> __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;
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-02 9:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30 23:39 [block/for-next] writeback: don't access page->mapping directly in track_foreign_dirty TP Tejun Heo
2019-08-31 1:54 ` Jens Axboe
2019-09-02 8:56 ` Jan Kara
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).