From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3E57C43334 for ; Thu, 16 Jun 2022 04:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356948AbiFPEP0 (ORCPT ); Thu, 16 Jun 2022 00:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358690AbiFPENO (ORCPT ); Thu, 16 Jun 2022 00:13:14 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26C7F58E79 for ; Wed, 15 Jun 2022 21:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655352778; x=1686888778; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=Nlm6al6P2Z1ikmMxhWHFF1HPFaPtHUR/HHWwJb+v9bI=; b=A0CKMjfJLP+PAjiQ/GCp9ZYYcCxK6iuKj0UwOoXhxRG14zNTqiiCAei7 cxPy8x4PvwmQwa2TNzJg/lgxn+szpr28Cpr3TTKcb8qE36MJR7VHM2rFN m1UvKLGP01uot1aXXg+Ip3yRKQug1jnHqfMEe6jmiUZXySmH4SBG+RBGu OIlYm/3iCqvjXrybH+EoiwLXyiABeYGU7PuPXxMsWrBtY3ZWboBNqSdtW /RPUtt1B4ethqHXnLDQ2uY356qiyppBu5HvaSA2fgDWvrh4ooss3csSmU /O3AxxBCo+K2s97JvPDYx+49pizNIJfiaiMo21Rxiqq9NzrbsnBoNgEDX Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10379"; a="340816689" X-IronPort-AV: E=Sophos;i="5.91,304,1647327600"; d="scan'208";a="340816689" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 21:12:48 -0700 X-IronPort-AV: E=Sophos;i="5.91,304,1647327600"; d="scan'208";a="652991681" Received: from schen9-mobl.amr.corp.intel.com ([10.209.78.147]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 21:12:47 -0700 Message-ID: Subject: Re: [RFC PATCH 2/3] mm/memory-tiers: Use page counter to track toptier memory usage From: Tim Chen To: Wei Xu Cc: Linux MM , Andrew Morton , Huang Ying , Greg Thelen , Yang Shi , Davidlohr Bueso , Brice Goglin , Michal Hocko , Linux Kernel Mailing List , Hesham Almatary , Dave Hansen , Jonathan Cameron , Alistair Popple , Dan Williams , Feng Tang , Jagdish Gediya , Baolin Wang , David Rientjes , "Aneesh Kumar K . V" , Shakeel Butt Date: Wed, 15 Jun 2022 21:12:47 -0700 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2022-06-14 at 17:30 -0700, Wei Xu wrote: Thanks for your comments. > When we don't know which pages are being charged, we should still > charge the usage to toptier (assuming that toptier always include the > default tier), e.g. from try_charge_memcg(). > I delayed the charging of the toptier a bit till we know which page is being used and the memcg is being assigned to the page. That's when mem_cgroup_charge_toptier is invoked. Otherwise if we charge to toptier first, we will have additional work to deduct the count when pages used are not toptier. > The idea is that when lower tier memory is not used, memcg->toptier > and memcg->memory should have the same value. Otherwise, it can cause > confusions about where the pages of (memcg->memory - memcg->toptier) > go. Any difference should be very small as the charge will go into toptier too quickly. The values will be different even if memcg->memory is read at slightly different time anyway. Tim