Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp288354pxb; Fri, 16 Apr 2021 05:52:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJZkWJHYVhc68G9J6zfM7x2yquS8hQZ+cFUJHTaMhxuhj5b9lsm+K+BQ2eWah6SNZ7hrnC X-Received: by 2002:a05:6402:397:: with SMTP id o23mr9635866edv.337.1618577524108; Fri, 16 Apr 2021 05:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618577524; cv=none; d=google.com; s=arc-20160816; b=zwaKWj/3FL/Vx0gwVJ1nmMOkBziP6NKt1iJUnhTdol6thqgY7RHAAduswSqJkYtQwr bKNFwRO6U35H+dp3cgeHnsPFsERRdzCTmT4Tc8eJvMMRQ43JIU7gXgqlkAuZLBa7Xy7B nCF7VSpkxDUJWmcaozwPJQ6X9lTgODB16bbiw6CMjyuxdh/9bckJBqHBubZh0GLSV/eq c0/8/q7uEugEtzJ6duRy887LsV0k32b7PhGu89sPgt3Kg4X96PFkurZ3eACiOvlAbEgX OPVSXwxKzx3PcuOXah1I3yZlPRNDYkD+wGml++sMhtxMBNfdWillrSWwlxh9ArGrYFf/ UeaQ== 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=/0NXzHc9C8GdWfSwnMIwDRzLMUHI+KIfop/E4cJH7Jg=; b=jiGybwrKiZhAmw/UuVs0uBSB0b9v7fqrzTCNm2nE0olBt7HcCWXIFk9EizeiyjXUJ+ slbO1z+AAO3dFPiiOJFxT8mnJn+s8NAYe2tDp09knR0F2lfq3gGETkNPFLQtid4yPt44 /gRUY+6C6l0scS6dD8uKT6KGDtSUp2S8bRAHYIG+wokknuJlwKPJDmRqVf5iB3bHxtMy OBPpWvj/6PRbVW2hLY1WFOXyIBcdTwenT5qS9+OHdgYhwRBOLc+0+1Xkhf2SwZCSrDkK 0g8D9awFpGpQmeIm80d/xAWNILuayCJKz2+T3IUYnfvSQcytgzvdUd3SfJtPpVUQJUpl Nq2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=tP9KOVED; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si1695235ejd.62.2021.04.16.05.51.41; Fri, 16 Apr 2021 05:52:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=tP9KOVED; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239122AbhDPMgL (ORCPT + 99 others); Fri, 16 Apr 2021 08:36:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:59416 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234291AbhDPMgL (ORCPT ); Fri, 16 Apr 2021 08:36:11 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1618576545; 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=/0NXzHc9C8GdWfSwnMIwDRzLMUHI+KIfop/E4cJH7Jg=; b=tP9KOVEDOaM7So8SGRLXgp7ANRlSAxH4MY5wrOUuBb6O31oVpHWz0GSj5wGPcIEvutyVrP hfbCN0DXoMql+zbEVRjZUU7+wKRk2TlzqvulmCyP2/Rl5a1kph9jVQXAZjdozRk1o/RSGq khWiykqBZJR77ljxa6TEMC84NO6U9is= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BDA68ABED; Fri, 16 Apr 2021 12:35:45 +0000 (UTC) Date: Fri, 16 Apr 2021 14:35:39 +0200 From: Michal Hocko To: Dave Hansen Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yang.shi@linux.alibaba.com, rientjes@google.com, ying.huang@intel.com, dan.j.williams@intel.com, david@redhat.com, osalvador@suse.de, weixugc@google.com Subject: Re: [PATCH 00/10] [v7][RESEND] Migrate Pages in lieu of discard Message-ID: References: <20210401183216.443C4443@viggo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210401183216.443C4443@viggo.jf.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I am really sorry to jump into this train sooo late. I have quickly glanced through the series and I have some questions/concerns. Let me express them here rather than in specific patches. First of all I do think that demotion is a useful way to balance the memory in general. And that is not really bound to PMEM equipped systems. There are larger NUMA machines which are not trivial to partition and our existing NUMA APIs are far from ideal to help with that. I do appreciate that the whole thing is an opt in because this might break workloads which are careful with the placement. I am not sure there is a way to handle constrains in an optimal way if that is possible at all in some cases (e.g. do we have a way to track page to its cpuset resp. task mempolicy in all cases?). The cover letter is focusing on usecases but it doesn't really provide so let me try to lay it down here (let's see whether I missed something important). - order for demontion defines a very simple fallback to a single node based on the proximity but cycles are not allowed in the fallback mask. I have to confess that I haven't grasped the initialization completely. There is a nice comment explaining a 2 socket system with 3 different NUMA nodes attached to it with one node being terminal. This is OK if the terminal node is PMEM but how that fits into usual NUMA setups. E.g. 4 nodes each with its set of CPUs node distances: node 0 1 2 3 0: 10 20 20 20 1: 20 10 20 20 2: 20 20 10 20 3: 20 20 20 10 Do I get it right that Node 3 would be terminal? - The demotion is controlled by node_reclaim_mode but unlike other modes it applies to both direct and kswapd reclaims. I do not see that explained anywhere though. - The demotion is implemented at shrink_page_list level which migrates pages in the first round and then falls back to the regular reclaim when migration fails. This means that the reclaim context (PF_MEMALLOC) will allocate memory so it has access to full memory reserves. Btw. I do not __GFP_NO_MEMALLOC anywhere in the allocation mask which looks like a bug rather than an intention. Btw. using GFP_NOWAIT in the allocation callback would make more things clear IMO. - Memcg reclaim is excluded from all this because it is not NUMA aware which makes sense to me. - Anonymous pages are bit tricky because they can be demoted even when they cannot be reclaimed due to no (or no available) swap storage. Unless I have missed something the second round will try to reclaim them even the later is true and I am not sure this is completely OK. I hope I've captured all important parts. There are some more details but they do not seem that important. I am still trying to digest the whole thing but at least jamming node_reclaim logic into kswapd seems strange to me. Need to think more about that though. Btw. do you have any numbers from running this with some real work workload? -- Michal Hocko SUSE Labs