Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753247AbdC2Q5b (ORCPT ); Wed, 29 Mar 2017 12:57:31 -0400 Received: from gum.cmpxchg.org ([85.214.110.215]:42734 "EHLO gum.cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752140AbdC2Q5a (ORCPT ); Wed, 29 Mar 2017 12:57:30 -0400 Date: Wed, 29 Mar 2017 12:57:22 -0400 From: Johannes Weiner To: "Huang, Ying" Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , "Kirill A . Shutemov" , Vladimir Davydov , Michal Hocko , Tejun Heo , cgroups@vger.kernel.org Subject: Re: [PATCH -mm -v7 2/9] mm, memcg: Support to charge/uncharge multiple swap entries Message-ID: <20170329165722.GB31821@cmpxchg.org> References: <20170328053209.25876-1-ying.huang@intel.com> <20170328053209.25876-3-ying.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170328053209.25876-3-ying.huang@intel.com> User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1104 Lines: 27 On Tue, Mar 28, 2017 at 01:32:02PM +0800, Huang, Ying wrote: > @@ -5908,16 +5907,19 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry) > css_put(&memcg->css); > } > > -/* > - * mem_cgroup_try_charge_swap - try charging a swap entry > +/** > + * mem_cgroup_try_charge_swap - try charging a set of swap entries > * @page: page being added to swap > - * @entry: swap entry to charge > + * @entry: the first swap entry to charge > + * @nr_entries: the number of swap entries to charge > * > - * Try to charge @entry to the memcg that @page belongs to. > + * Try to charge @nr_entries swap entries starting from @entry to the > + * memcg that @page belongs to. > * > * Returns 0 on success, -ENOMEM on failure. > */ > -int mem_cgroup_try_charge_swap(struct page *page, swp_entry_t entry) > +int mem_cgroup_try_charge_swap(struct page *page, swp_entry_t entry, > + unsigned int nr_entries) I've pointed this out before, but there doesn't seem to be a reason to pass @nr_entries when we have the struct page. Why can't this function just check PageTransHuge() by itself?