From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Huang\, Ying" Subject: Re: [PATCH -mm -v7 2/9] mm, memcg: Support to charge/uncharge multiple swap entries Date: Thu, 30 Mar 2017 08:53:50 +0800 Message-ID: <87k277twip.fsf@yhuang-dev.intel.com> References: <20170328053209.25876-1-ying.huang@intel.com> <20170328053209.25876-3-ying.huang@intel.com> <20170329165722.GB31821@cmpxchg.org> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490835235; x=1522371235; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=HOhwSZ7SpOsTsiPCarG5CTTbLQJ32Wrxzq+3g/HgQLk=; b=Ht+/Brtk4DbYcDa5tQMPcnaBW4CFFDSS3oltpwZ78VXcTlzCL+KSvpU4 imnggheLLNouHossN9I4PIesQ8EGvg==; In-Reply-To: <20170329165722.GB31821-druUgvl0LCNAfugRpC6u6w@public.gmane.org> (Johannes Weiner's message of "Wed, 29 Mar 2017 12:57:22 -0400") Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Johannes Weiner Cc: "Huang, Ying" , Andrew Morton , linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andrea Arcangeli , "Kirill A . Shutemov" , Vladimir Davydov , Michal Hocko , Tejun Heo , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Johannes Weiner writes: > 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, Yes. And I have replied to your original comments too :-) > 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? Because sometimes we need to charge one swap entry for a THP. Please take a look at the original add_to_swap() implementation. For a THP, one swap entry will be allocated and charged to the mem cgroup before the THP is split. And I think it is not easy to change this, because we don't want to split THP if the mem cgroup for swap exceeds its limit. Best Regards, Huang, Ying From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id 409A06B0390 for ; Wed, 29 Mar 2017 20:53:58 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id n129so26903389pga.0 for ; Wed, 29 Mar 2017 17:53:58 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id v5si445333pgj.302.2017.03.29.17.53.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Mar 2017 17:53:57 -0700 (PDT) From: "Huang\, Ying" Subject: Re: [PATCH -mm -v7 2/9] mm, memcg: Support to charge/uncharge multiple swap entries References: <20170328053209.25876-1-ying.huang@intel.com> <20170328053209.25876-3-ying.huang@intel.com> <20170329165722.GB31821@cmpxchg.org> Date: Thu, 30 Mar 2017 08:53:50 +0800 In-Reply-To: <20170329165722.GB31821@cmpxchg.org> (Johannes Weiner's message of "Wed, 29 Mar 2017 12:57:22 -0400") Message-ID: <87k277twip.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: owner-linux-mm@kvack.org List-ID: To: Johannes Weiner Cc: "Huang, Ying" , 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 Johannes Weiner writes: > 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, Yes. And I have replied to your original comments too :-) > 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? Because sometimes we need to charge one swap entry for a THP. Please take a look at the original add_to_swap() implementation. For a THP, one swap entry will be allocated and charged to the mem cgroup before the THP is split. And I think it is not easy to change this, because we don't want to split THP if the mem cgroup for swap exceeds its limit. Best Regards, Huang, Ying -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933243AbdC3Ax5 (ORCPT ); Wed, 29 Mar 2017 20:53:57 -0400 Received: from mga01.intel.com ([192.55.52.88]:49777 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932971AbdC3Axz (ORCPT ); Wed, 29 Mar 2017 20:53:55 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,244,1486454400"; d="scan'208";a="1148604354" From: "Huang\, Ying" To: Johannes Weiner Cc: "Huang\, Ying" , Andrew Morton , , , Andrea Arcangeli , "Kirill A . Shutemov" , Vladimir Davydov , Michal Hocko , Tejun Heo , Subject: Re: [PATCH -mm -v7 2/9] mm, memcg: Support to charge/uncharge multiple swap entries References: <20170328053209.25876-1-ying.huang@intel.com> <20170328053209.25876-3-ying.huang@intel.com> <20170329165722.GB31821@cmpxchg.org> Date: Thu, 30 Mar 2017 08:53:50 +0800 In-Reply-To: <20170329165722.GB31821@cmpxchg.org> (Johannes Weiner's message of "Wed, 29 Mar 2017 12:57:22 -0400") Message-ID: <87k277twip.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Johannes Weiner writes: > 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, Yes. And I have replied to your original comments too :-) > 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? Because sometimes we need to charge one swap entry for a THP. Please take a look at the original add_to_swap() implementation. For a THP, one swap entry will be allocated and charged to the mem cgroup before the THP is split. And I think it is not easy to change this, because we don't want to split THP if the mem cgroup for swap exceeds its limit. Best Regards, Huang, Ying