Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

writeback: don't access page->mapping directly in track_foreign_dirty TP

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.

Fixes: 3a8e9ac89e6a ("writeback: add tracepoints for cgroup foreign writebacks")
Reported-by: Jan Kara <jack@suse.cz>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Tejun Heo and committed by
Jens Axboe
0feacaa2 8f5914bc

+4 -1
+4 -1
include/trace/events/writeback.h
··· 251 251 ), 252 252 253 253 TP_fast_assign( 254 + struct address_space *mapping = page_mapping(page); 255 + struct inode *inode = mapping ? mapping->host : NULL; 256 + 254 257 strncpy(__entry->name, dev_name(wb->bdi->dev), 32); 255 258 __entry->bdi_id = wb->bdi->id; 256 - __entry->ino = page->mapping->host->i_ino; 259 + __entry->ino = inode ? inode->i_ino : 0; 257 260 __entry->memcg_id = wb->memcg_css->id; 258 261 __entry->cgroup_ino = __trace_wb_assign_cgroup(wb); 259 262 __entry->page_cgroup_ino = page->mem_cgroup->css.cgroup->kn->id.ino;