Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp303879rwi; Thu, 27 Oct 2022 01:10:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6b+wNuO0hlwroukMaZlKql3j9n6qpM5lrrRQUB6OhdWKu3K08Q5mC9dDU/4GlWSx4c6o2V X-Received: by 2002:a17:907:80b:b0:77a:86a1:db52 with SMTP id wv11-20020a170907080b00b0077a86a1db52mr42545045ejb.294.1666858253323; Thu, 27 Oct 2022 01:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666858253; cv=none; d=google.com; s=arc-20160816; b=Nywtzh8DGf8KQc4uYC0iybGvVD8OhiuQy0WH0+nY26TJgpIqYNkPo7ID9/wsjnZkpn 5zCFjB7uwdINDKHRm33K3OR9uXs0BtN0K6ihfk6E4+iG7yV9+/KoWlpQ4dv/ALE9CXgl 7VYxKmjVDAe8CD2gwp+WQ06q5B4JDLIQARhsI7lCRwEJECXIsWQKXuL9LvpNjWgBBHph /MP2qD7r58iXHRgczwTEZVjhkrfxw+6AhEYGtMQwO8xF0/cKvr3FoZ59RBTedHOBYLLj ilxIR1yWCJhIGk82J88EDdjA1Gh4xW+2cHqh3GdLeJ9lcqipeNHmkk4kLbAD3I4Nl66d JDkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qa6sD3OJX290NYnGc0ulUW01Mac/lvuPb2vaepZWVak=; b=XnXi3P0a/efdqe1NRAjOH1pWfp7gGB+JWoJzvFtcbahCkbtDLpQ4+w82osA4+jH9oq cwkbBR0+cP4sT0tcj/80ziJ9wjWFRK1OzZdssddvQ+ZPCNhFnFoXnsQloCmHgTdmDdc5 zfHJtfVv3Xe//1fFDjcgMHUy4qnm3Aw8eES6+osMxBhTuuMzNg66oM5UVljOSkYQnM5L bkqt3QItX4zXW6xDQkw6Iux1kAPo3qDylnqrmcrgc3YaKpz1XWCG7i0SSFPdkMOaJLAI L/Hs9zAeSj4d0wkvsvM4R4WlvOsmLv9WKhgmFduLJEAtlU6gsVpU3f6ccA1H1Vz/lsmY Wx/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="GOfRQdi/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb39-20020a1709077ea700b0078b96722000si941639ejc.608.2022.10.27.01.10.27; Thu, 27 Oct 2022 01:10:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="GOfRQdi/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234596AbiJ0IBl (ORCPT + 99 others); Thu, 27 Oct 2022 04:01:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233497AbiJ0IBh (ORCPT ); Thu, 27 Oct 2022 04:01:37 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE480C34DD; Thu, 27 Oct 2022 01:01:35 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0382322889; Thu, 27 Oct 2022 08:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1666857694; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qa6sD3OJX290NYnGc0ulUW01Mac/lvuPb2vaepZWVak=; b=GOfRQdi/m0WYSTD5CYAhkOmN4NswRTwudSaHgtIJ1oHw16QVwyrpau8AnA+4eYPePOcGhe 4VPRB2hWHIuofx9bzVfEvuQ+PfHUE5qM3DhDGpewPt3/bELf+bC3WB+x4DEvQu67yIfq1O IKDmab7lHY5SApO2WVHdJr/goa+3CBw= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CFE08134CA; Thu, 27 Oct 2022 08:01:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RhNlL906WmNTNAAAMHmgww (envelope-from ); Thu, 27 Oct 2022 08:01:33 +0000 Date: Thu, 27 Oct 2022 10:01:33 +0200 From: Michal Hocko To: "Huang, Ying" 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 Message-ID: References: <20221026074343.6517-1-feng.tang@intel.com> <87wn8lkbk5.fsf@yhuang6-desk2.ccr.corp.intel.com> <87o7txk963.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87o7txk963.fsf@yhuang6-desk2.ccr.corp.intel.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > >From overhead point of view, this appears similar as that of VMA/task > memory policy? We can make mm->owner available for memory tiers > (CONFIG_NUMA && CONFIG_MIGRATION). The advantage is that we don't need > to introduce new ABI. I guess users may prefer to use `numactl` than a > new ABI? mm->owner is a wrong direction. It doesn't have a strong meaning because there is no one task explicitly responsible for the mm so there is no real owner (our clone() semantic is just to permissive for that). The memcg::owner is a crude and ugly hack and it should go away over time rather than build new uses. Besides that, and as I have already tried to explain, per task demotion policy is what makes this whole thing expensive. So this better be a per mm or per vma property. Whether it is a on/off knob like PR_[GS]ET_THP_DISABLE or there are explicit requirements for fine grain control on the vma level I dunno. I haven't seen those usecases yet and it is really easy to overengineer this. To be completely honest I would much rather wait for those usecases before adding a more complex APIs. PR_[GS]_DEMOTION_DISABLED sounds like a reasonable first step. Should we have more fine grained requirements wrt address space I would follow the MADV_{NO}HUGEPAGE lead. 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. -- Michal Hocko SUSE Labs