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 52315ECAAA1 for ; Thu, 27 Oct 2022 23:23:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB0E56B0072; Thu, 27 Oct 2022 19:23:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A608D6B0073; Thu, 27 Oct 2022 19:23:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94F3F6B0074; Thu, 27 Oct 2022 19:23:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 877A76B0072 for ; Thu, 27 Oct 2022 19:23:19 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5353D80527 for ; Thu, 27 Oct 2022 23:23:19 +0000 (UTC) X-FDA: 80068307718.30.526A9E8 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf15.hostedemail.com (Postfix) with ESMTP id C5241A0037 for ; Thu, 27 Oct 2022 23:23:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666912997; x=1698448997; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=qctRSNSWHaYKZhhzWADPStHUQ6ZRSzyF7S51wP2f2Yw=; b=Ci5gmqsjgNdylKhG4EEWae+p7p/VhJC6CKuyrPdbdstzo6lA7V7Mn/Tk xtWUGRv5tRGCc+XO5F1cOcgGCfe3qLhqEtDnFq+rke2MgoRgH7d3Jyvgc P8/XGRI9jmalu5RHpiXLPSIYE473567JBLUPQ4jtI+Athawq+RG6+falJ e1H3ADthE/FwXFUN5Cnotex7zsStGDM0hq8w4uxDYT+9Tg5fYepS0RTAV EDuP3qJxWCHdicG0+mwmmtTzPyhctNRWfXU3z+ZFR1uKZHT03U65fAKTZ zvWdlqkTjhw1j4xq2UEbsL+5sl38I3JuXic5Okwen/Utb27tA+P0vC/bj Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10513"; a="372577457" X-IronPort-AV: E=Sophos;i="5.95,219,1661842800"; d="scan'208";a="372577457" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2022 16:23:16 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10513"; a="627340917" X-IronPort-AV: E=Sophos;i="5.95,219,1661842800"; d="scan'208";a="627340917" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2022 16:23:12 -0700 From: "Huang, Ying" To: Michal Hocko Cc: Feng Tang , Aneesh Kumar K V , Andrew Morton , Johannes Weiner , Tejun Heo , Zefan Li , Waiman Long , "linux-mm@kvack.org" , "cgroups@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Hansen, Dave" , "Chen, Tim C" , "Yin, Fengwei" Subject: Re: [PATCH] mm/vmscan: respect cpuset policy during page demotion References: <87wn8lkbk5.fsf@yhuang6-desk2.ccr.corp.intel.com> <87o7txk963.fsf@yhuang6-desk2.ccr.corp.intel.com> <87fsf9k3yg.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Fri, 28 Oct 2022 07:22:27 +0800 In-Reply-To: (Michal Hocko's message of "Thu, 27 Oct 2022 14:29:49 +0200") Message-ID: <87bkpwkg24.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666912998; a=rsa-sha256; cv=none; b=WUKRtmuF/qc+JrVXduzeronvObSDcLjxJX+87QSlzWAAUAp6ze0ShmZiQRdCmoDW0zkvXj ibSFTMmzlymBQ/tNJW+wUA537pqKbUjcNpMCGwCuxBG8FRiNlM/8w/1wHHmyySpdoGsGdS wsh/6oZ2SfjNXNalWHTZ8eQsixiqaQw= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=Ci5gmqsj; spf=pass (imf15.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666912998; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/VQKcgsqmzKfQriBT4/6lFMKKVaUA5RDcDIG0A8K4oY=; b=HwZ0QRWx8v+ZelTttQWY3TN+WLjrRx908mE4y0EUl5Vr3SewRTyWaCqsWqfQf+5crwbrU/ 4jGuCY9pidjWAPt2Z/Ph8TL8zjUm60Ivctw0/J+Jdy8e53uu2vF6nPftpdfhkmZ0LZhU7L re/jTCq8fN68VNtEwrnezqfR0Q1486g= Authentication-Results: imf15.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=Ci5gmqsj; spf=pass (imf15.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C5241A0037 X-Stat-Signature: 94zarzp8z7duk3378cf8s5zw8aurd6zt X-Rspam-User: X-HE-Tag: 1666912997-508191 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: Michal Hocko writes: > On Thu 27-10-22 17:31:35, Huang, Ying wrote: >> Michal Hocko writes: >> >> > On Thu 27-10-22 15:39:00, Huang, Ying wrote: >> >> Michal Hocko writes: >> >> >> >> > On Thu 27-10-22 14:47:22, Huang, Ying wrote: >> >> >> Michal Hocko writes: >> >> > [...] >> >> >> > I can imagine workloads which wouldn't like to get their memory demoted >> >> >> > for some reason but wouldn't it be more practical to tell that >> >> >> > explicitly (e.g. via prctl) rather than configuring cpusets/memory >> >> >> > policies explicitly? >> >> >> >> >> >> If my understanding were correct, prctl() configures the process or >> >> >> thread. >> >> > >> >> > Not necessarily. There are properties which are per adddress space like >> >> > PR_[GS]ET_THP_DISABLE. This could be very similar. >> >> > >> >> >> How can we get process/thread configuration at demotion time? >> >> > >> >> > As already pointed out in previous emails. You could hook into >> >> > folio_check_references path, more specifically folio_referenced_one >> >> > where you have all that you need already - all vmas mapping the page and >> >> > then it is trivial to get the corresponding vm_mm. If at least one of >> >> > them has the flag set then the demotion is not allowed (essentially the >> >> > same model as VM_LOCKED). >> >> >> >> Got it! Thanks for detailed explanation. >> >> >> >> One bit may be not sufficient. For example, if we want to avoid or >> >> control cross-socket demotion and still allow demoting to slow memory >> >> nodes in local socket, we need to specify a node mask to exclude some >> >> NUMA nodes from demotion targets. >> > >> > Isn't this something to be configured on the demotion topology side? Or >> > do you expect there will be per process/address space usecases? I mean >> > different processes running on the same topology, one requesting local >> > demotion while other ok with the whole demotion topology? >> >> I think that it's possible for different processes have different >> requirements. >> >> - Some processes don't care about where the memory is placed, prefer >> local, then fall back to remote if no free space. >> >> - Some processes want to avoid cross-socket traffic, bind to nodes of >> local socket. >> >> - Some processes want to avoid to use slow memory, bind to fast memory >> node only. > > Yes, I do understand that. Do you have any specific examples in mind? > [...] Sorry, I don't have specific examples. >> > If we really need/want to give a fine grained control over demotion >> > nodemask then we would have to go with vma->mempolicy interface. In >> > any case a per process on/off knob sounds like a reasonable first step >> > before we learn more about real usecases. >> >> Yes. Per-mm or per-vma property is much better than per-task property. >> Another possibility, how about add a new flag to set_mempolicy() system >> call to set the per-mm mempolicy? `numactl` can use that by default. > > Do you mean a flag to control whether the given policy is applied to a > task or mm? Yes. That is the idea. Best Regards, Huang, Ying