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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40536C43334 for ; Thu, 16 Jun 2022 04:12:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE6406B0072; Thu, 16 Jun 2022 00:12:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBCE46B0073; Thu, 16 Jun 2022 00:12:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5CF56B0074; Thu, 16 Jun 2022 00:12:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 97A076B0072 for ; Thu, 16 Jun 2022 00:12:58 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 6AE316118F for ; Thu, 16 Jun 2022 04:12:58 +0000 (UTC) X-FDA: 79582778436.04.5A1FCE8 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf19.hostedemail.com (Postfix) with ESMTP id 7BE7B1A0082 for ; Thu, 16 Jun 2022 04:12:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655352777; x=1686888777; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=Nlm6al6P2Z1ikmMxhWHFF1HPFaPtHUR/HHWwJb+v9bI=; b=PF8DpzzWfuZVRbxC8t/dkU9KU0+1GmqmNmXpii6j1sR/Vl+pNpZka5tF QIkcFptIAHt/S0K4PdWugHgJAOQTpVBUZgAv4Bh1L8NJaOIHaa4SD13D3 mjRSUn9U/XeYzeDEgiK74UMUsvpJAJXZ9Vqdy5riD8bOsVvbtF7EZjFDb NYgFjcWqkToc0Qq24CLCLkNMTUr3DJ06YDUslk/wrBhAS2bwJmGxhraA2 vPS00VUY4yr+H/hdL1bPfJlEyRnFgDHzHXKvUo9TkpAPnB+DgTi5Blvth TuO7eryloB95PS3NiMg9JL+u/LI2Ab6CZ3mx78IES+/MBEnErgXrsQT52 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10379"; a="343119666" X-IronPort-AV: E=Sophos;i="5.91,304,1647327600"; d="scan'208";a="343119666" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655352777; a=rsa-sha256; cv=none; b=LY9O5wU4u09EQAStkYRYvGox+We6vextwatItW3Yc66TpdMGe97B7F4xZabiK/Ry9zbmYz idEBymuEgsEtPmmCUeV+4smPm8eZCZsDSVnqxN222ubC+jP0nce/2632NSZKjIGCa8cZwF g4zmvkEmUyqdjG4X1bg1DRxRm9KFuVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655352777; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Eik8yDSufYc1nTS6clL8XGI9b9svOM63pN8wd+B0sS4=; b=VtchOOMrZzP4adu1l9MYrNWfKXcHOj6xyDa5SLCJATyYZw/S9+G02Za4tXsDME9pQDQsbl XSSIHfF8l2R9qz4MBVf4KfkPXVWo0UeXPCiZYhKfv8yxY6GLwb4JPVE3n28z62OG6PmkZz RrnYndTFGhgBrLn4V2K2iVzt5+9ip4k= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=PF8DpzzW; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf19.hostedemail.com: domain of tim.c.chen@linux.intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=tim.c.chen@linux.intel.com Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=PF8DpzzW; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf19.hostedemail.com: domain of tim.c.chen@linux.intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=tim.c.chen@linux.intel.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7BE7B1A0082 X-Stat-Signature: xrgq1rowq8jha8xnjj3cxjp8zqz9tjtx X-HE-Tag: 1655352777-718839 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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