Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1379079pxb; Thu, 14 Apr 2022 05:03:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/tq8fiMKlGbX2VLk9OfKoLszNNyOjaFHtm95tlaOGneV7aYdyoI10vNb6lDeVWS3ciU94 X-Received: by 2002:a05:6402:1d51:b0:41f:cf6c:35a5 with SMTP id dz17-20020a0564021d5100b0041fcf6c35a5mr2617135edb.25.1649937808270; Thu, 14 Apr 2022 05:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649937808; cv=none; d=google.com; s=arc-20160816; b=zqZ2OQDoCUPPAdJ9r+St+nWPxWpqzQWGHcb/2Cc0I695jUBIkIGwuTnOPdWLuWQ0PA wORDkkrBwYEK+tDirbx874KJJ5Q6mHy//zepqqYHArb+Fr1ECgiKb3JY2bVHmavNzDC8 EdmNMf4FMHSIfBVEJDoxIKUFHzEhfkLMsq3lZuKfaPRJ6xwAsXNhykU9buneEPr4urf8 IPQSQ1BHElr+N5pYbgNNzrOp87vJEaNbiuFhWh2LObUWNgjQWr6PfwfAb8oidphf80eP MSHznek51ks4GIeYNud1Nif/P6WNJ0NryEp8d4WaQIQMEf7CWNX8hYDKkvBgz5fO9ZjS I8uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=NgzTsoRjlhv85jfIKhu0xNtmoZiwYdvLPc+itGa4Sb4=; b=jQu0BSVxuX5mDYg4ZkPONMJ2HwiypvPb+TvDBIIMGyJF+t6YCvmJmfg7TcH6VSA7IS sc+5QgsM5+PwZgHZ23ZpfKMhrXaFJVmJ22iYtk4dhdNTk4A5w2vrlNAVWjkGls5citZr k1mGRj1at0F8E+kaFNzd+9hmMnWtmHM9uQWx76XBnSYErLS7vH1Ug0Y2xSYu8EB6epN4 uO24R8GIZhbaHD2uXxvJ3X9Ri4mb60oRBPFdWdlt8tQZ0UyLzLcdede8gXYSKwuQL5jo KUlMci79y4tjQ4KffGUwegAgMxaZPJv1Us0rcl1byXKmyLKHVBUOKeqpKE1kPCJennuT dLGg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gv1-20020a1709072bc100b006e8aea64e6esi1688181ejc.29.2022.04.14.05.03.02; Thu, 14 Apr 2022 05:03:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241217AbiDNI5N (ORCPT + 99 others); Thu, 14 Apr 2022 04:57:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbiDNI5L (ORCPT ); Thu, 14 Apr 2022 04:57:11 -0400 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14FE12C116 for ; Thu, 14 Apr 2022 01:54:46 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VA1gCSM_1649926482; Received: from 30.39.165.7(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VA1gCSM_1649926482) by smtp.aliyun-inc.com(127.0.0.1); Thu, 14 Apr 2022 16:54:43 +0800 Message-ID: Date: Thu, 14 Apr 2022 16:55:27 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2 1/5] mm: demotion: Set demotion list differently To: Jagdish Gediya , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, aneesh.kumar@linux.ibm.com, dave.hansen@linux.intel.com, ying.huang@intel.com References: <20220413092206.73974-1-jvgediya@linux.ibm.com> <20220413092206.73974-2-jvgediya@linux.ibm.com> From: Baolin Wang In-Reply-To: <20220413092206.73974-2-jvgediya@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 4/13/2022 5:22 PM, Jagdish Gediya wrote: > Sharing used_targets between multiple nodes in a single > pass limits some of the opportunities for demotion target > sharing. > > Don't share the used targets between multiple nodes in a > single pass, instead accumulate all the used targets in > source nodes shared by all pass, and reset 'used_targets' > to source nodes while finding demotion targets for any new > node. > > This results into some more opportunities to share demotion > targets between multiple source nodes, e.g. with below NUMA > topology, where node 0 & 1 are cpu + dram nodes, node 2 & 3 > are equally slower memory only nodes, and node 4 is slowest > memory only node, > > available: 5 nodes (0-4) > node 0 cpus: 0 1 > node 0 size: n MB > node 0 free: n MB > node 1 cpus: 2 3 > node 1 size: n MB > node 1 free: n MB > node 2 cpus: > node 2 size: n MB > node 2 free: n MB > node 3 cpus: > node 3 size: n MB > node 3 free: n MB > node 4 cpus: > node 4 size: n MB > node 4 free: n MB > node distances: > node 0 1 2 3 4 > 0: 10 20 40 40 80 > 1: 20 10 40 40 80 > 2: 40 40 10 40 80 > 3: 40 40 40 10 80 > 4: 80 80 80 80 10 > > The existing implementation gives below demotion targets, > > node demotion_target > 0 3, 2 > 1 4 > 2 X > 3 X > 4 X > > With this patch applied, below are the demotion targets, > > node demotion_target > 0 3, 2 > 1 3, 2 > 2 4 > 3 4 > 4 X > > e.g. with below NUMA topology, where node 0, 1 & 2 are > cpu + dram nodes and node 3 is slow memory node, > > available: 4 nodes (0-3) > node 0 cpus: 0 1 > node 0 size: n MB > node 0 free: n MB > node 1 cpus: 2 3 > node 1 size: n MB > node 1 free: n MB > node 2 cpus: 4 5 > node 2 size: n MB > node 2 free: n MB > node 3 cpus: > node 3 size: n MB > node 3 free: n MB > node distances: > node 0 1 2 3 > 0: 10 20 20 40 > 1: 20 10 20 40 > 2: 20 20 10 40 > 3: 40 40 40 10 > > The existing implementation gives below demotion targets, > > node demotion_target > 0 3 > 1 X > 2 X > 3 X > > With this patch applied, below are the demotion targets, > > node demotion_target > 0 3 > 1 3 > 2 3 > 3 X > > Signed-off-by: Aneesh Kumar K.V > Signed-off-by: Jagdish Gediya > --- Looks reasonable to me. Please feel free to add: Reviewed-by: Baolin Wang Tested-by: Baolin Wang > mm/migrate.c | 25 ++++++++++++++----------- > 1 file changed, 14 insertions(+), 11 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index de175e2fdba5..516f4e1348c1 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -2383,7 +2383,7 @@ static void __set_migration_target_nodes(void) > { > nodemask_t next_pass = NODE_MASK_NONE; > nodemask_t this_pass = NODE_MASK_NONE; > - nodemask_t used_targets = NODE_MASK_NONE; > + nodemask_t source_nodes = NODE_MASK_NONE; > int node, best_distance; > > /* > @@ -2401,20 +2401,23 @@ static void __set_migration_target_nodes(void) > again: > this_pass = next_pass; > next_pass = NODE_MASK_NONE; > + > /* > - * To avoid cycles in the migration "graph", ensure > - * that migration sources are not future targets by > - * setting them in 'used_targets'. Do this only > - * once per pass so that multiple source nodes can > - * share a target node. > - * > - * 'used_targets' will become unavailable in future > - * passes. This limits some opportunities for > - * multiple source nodes to share a destination. > + * Accumulate source nodes to avoid the cycle in migration > + * list. > */ > - nodes_or(used_targets, used_targets, this_pass); > + nodes_or(source_nodes, source_nodes, this_pass); > > for_each_node_mask(node, this_pass) { > + /* > + * To avoid cycles in the migration "graph", ensure > + * that migration sources are not future targets by > + * setting them in 'used_targets'. Reset used_targets > + * to source nodes for each node in this pass so that > + * multiple source nodes can share a target node. > + */ > + nodemask_t used_targets = source_nodes; > + > best_distance = -1; > > /*