Skip to content

Commit a18b9b1

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: move bio_associate_blkg_from_page to mm/page_io.c
bio_associate_blkg_from_page is a special purpose helper for swap bios that doesn't need access to bio internals. Move it to the swap code instead of having it in bio.c. Acked-by: Tejun Heo <tj@kernel.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2badf06 commit a18b9b1

3 files changed

Lines changed: 17 additions & 33 deletions

File tree

‎block/bio.c‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,32 +1659,6 @@ void bio_associate_blkg_from_css(struct bio *bio,
16591659
}
16601660
EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css);
16611661

1662-
#ifdef CONFIG_MEMCG
1663-
/**
1664-
* bio_associate_blkg_from_page - associate a bio with the page's blkg
1665-
* @bio: target bio
1666-
* @page: the page to lookup the blkcg from
1667-
*
1668-
* Associate @bio with the blkg from @page's owning memcg and the respective
1669-
* request_queue. If cgroup_e_css returns %NULL, fall back to the queue's
1670-
* root_blkg.
1671-
*/
1672-
void bio_associate_blkg_from_page(struct bio *bio, struct page *page)
1673-
{
1674-
struct cgroup_subsys_state *css;
1675-
1676-
if (!page->mem_cgroup)
1677-
return;
1678-
1679-
rcu_read_lock();
1680-
1681-
css = cgroup_e_css(page->mem_cgroup->css.cgroup, &io_cgrp_subsys);
1682-
bio_associate_blkg_from_css(bio, css);
1683-
1684-
rcu_read_unlock();
1685-
}
1686-
#endif /* CONFIG_MEMCG */
1687-
16881662
/**
16891663
* bio_associate_blkg - associate a bio with a blkg
16901664
* @bio: target bio

‎include/linux/bio.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,6 @@ do { \
489489
#define bio_dev(bio) \
490490
disk_devt((bio)->bi_disk)
491491

492-
#if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
493-
void bio_associate_blkg_from_page(struct bio *bio, struct page *page);
494-
#else
495-
static inline void bio_associate_blkg_from_page(struct bio *bio,
496-
struct page *page) { }
497-
#endif
498-
499492
#ifdef CONFIG_BLK_CGROUP
500493
void bio_associate_blkg(struct bio *bio);
501494
void bio_associate_blkg_from_css(struct bio *bio,

‎mm/page_io.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,23 @@ static inline void count_swpout_vm_event(struct page *page)
277277
count_vm_events(PSWPOUT, hpage_nr_pages(page));
278278
}
279279

280+
#if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
281+
static void bio_associate_blkg_from_page(struct bio *bio, struct page *page)
282+
{
283+
struct cgroup_subsys_state *css;
284+
285+
if (!page->mem_cgroup)
286+
return;
287+
288+
rcu_read_lock();
289+
css = cgroup_e_css(page->mem_cgroup->css.cgroup, &io_cgrp_subsys);
290+
bio_associate_blkg_from_css(bio, css);
291+
rcu_read_unlock();
292+
}
293+
#else
294+
#define bio_associate_blkg_from_page(bio, page) do { } while (0)
295+
#endif /* CONFIG_MEMCG && CONFIG_BLK_CGROUP */
296+
280297
int __swap_writepage(struct page *page, struct writeback_control *wbc,
281298
bio_end_io_t end_write_func)
282299
{

0 commit comments

Comments
 (0)