The patch titled Subject: page_cgroup: add helper function to get swap_cgroup has been added to the -mm tree. Its filename is page_cgroup-add-helper-function-to-get-swap_cgroup.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ From: Bob Liu <lliubbo@xxxxxxxxx> Subject: page_cgroup: add helper function to get swap_cgroup There are multiple places which need to get the swap_cgroup address, so add a helper function: static struct swap_cgroup *swap_cgroup_getsc(swp_entry_t ent, struct swap_cgroup_ctrl **ctrl); to simplify the code. Signed-off-by: Bob Liu <lliubbo@xxxxxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxx> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> Cc: Johannes Weiner <jweiner@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/page_cgroup.c | 57 ++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff -puN mm/page_cgroup.c~page_cgroup-add-helper-function-to-get-swap_cgroup mm/page_cgroup.c --- a/mm/page_cgroup.c~page_cgroup-add-helper-function-to-get-swap_cgroup +++ a/mm/page_cgroup.c @@ -376,6 +376,27 @@ not_enough_page: return -ENOMEM; } +static struct swap_cgroup *swap_cgroup_getsc(swp_entry_t ent, + struct swap_cgroup_ctrl **ctrl) +{ + int type = swp_type(ent); + unsigned long offset = swp_offset(ent); + unsigned long idx = offset / SC_PER_PAGE; + unsigned long pos = offset & SC_POS_MASK; + struct swap_cgroup_ctrl *temp_ctrl; + struct page *mappage; + struct swap_cgroup *sc; + + temp_ctrl = &swap_cgroup_ctrl[type]; + if (ctrl) + *ctrl = temp_ctrl; + + mappage = temp_ctrl->map[idx]; + sc = page_address(mappage); + sc += pos; + return sc; +} + /** * swap_cgroup_cmpxchg - cmpxchg mem_cgroup's id for this swp_entry. * @end: swap entry to be cmpxchged @@ -388,21 +409,13 @@ not_enough_page: unsigned short swap_cgroup_cmpxchg(swp_entry_t ent, unsigned short old, unsigned short new) { - int type = swp_type(ent); - unsigned long offset = swp_offset(ent); - unsigned long idx = offset / SC_PER_PAGE; - unsigned long pos = offset & SC_POS_MASK; struct swap_cgroup_ctrl *ctrl; - struct page *mappage; struct swap_cgroup *sc; unsigned long flags; unsigned short retval; - ctrl = &swap_cgroup_ctrl[type]; + sc = swap_cgroup_getsc(ent, &ctrl); - mappage = ctrl->map[idx]; - sc = page_address(mappage); - sc += pos; spin_lock_irqsave(&ctrl->lock, flags); retval = sc->id; if (retval == old) @@ -423,21 +436,13 @@ unsigned short swap_cgroup_cmpxchg(swp_e */ unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id) { - int type = swp_type(ent); - unsigned long offset = swp_offset(ent); - unsigned long idx = offset / SC_PER_PAGE; - unsigned long pos = offset & SC_POS_MASK; struct swap_cgroup_ctrl *ctrl; - struct page *mappage; struct swap_cgroup *sc; unsigned short old; unsigned long flags; - ctrl = &swap_cgroup_ctrl[type]; + sc = swap_cgroup_getsc(ent, &ctrl); - mappage = ctrl->map[idx]; - sc = page_address(mappage); - sc += pos; spin_lock_irqsave(&ctrl->lock, flags); old = sc->id; sc->id = id; @@ -454,21 +459,7 @@ unsigned short swap_cgroup_record(swp_en */ unsigned short lookup_swap_cgroup(swp_entry_t ent) { - int type = swp_type(ent); - unsigned long offset = swp_offset(ent); - unsigned long idx = offset / SC_PER_PAGE; - unsigned long pos = offset & SC_POS_MASK; - struct swap_cgroup_ctrl *ctrl; - struct page *mappage; - struct swap_cgroup *sc; - unsigned short ret; - - ctrl = &swap_cgroup_ctrl[type]; - mappage = ctrl->map[idx]; - sc = page_address(mappage); - sc += pos; - ret = sc->id; - return ret; + return swap_cgroup_getsc(ent, NULL)->id; } int swap_cgroup_swapon(int type, unsigned long max_pages) _ Subject: Subject: page_cgroup: add helper function to get swap_cgroup Patches currently in -mm which might be from lliubbo@xxxxxxxxx are linux-next.patch page_cgroup-add-helper-function-to-get-swap_cgroup.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html