Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp92168iof; Sun, 5 Jun 2022 22:06:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuWVPsmPaWYHOHtzAgmi+qNOP7yo+DWFhQnCIUFoCj3bPsUvZSp72mH+nizkF5x1lOOxmM X-Received: by 2002:a17:902:c951:b0:163:ed13:7acd with SMTP id i17-20020a170902c95100b00163ed137acdmr22874019pla.51.1654492014478; Sun, 05 Jun 2022 22:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654492014; cv=none; d=google.com; s=arc-20160816; b=GAF0I5yiVmsODvDsh7wm+e3LfCvPDZmbM6WrssSgLSQJ2S4eAkyEw4dyFXyEs5Picb yzdgfkqnfE9keBA5PDa4d/xDckdvdY89WL1UgaQhr2gGUGddedkTWaT/pLbHw1zbdtz5 jPanSrzZJV6deXmbqeY6ZOGmMLrQRqzegksYkbGQWYvWXkowyr67kSAPVmsTIrvmTCGl HNreAJyaVDYBv2tgFtPAOGx6aJExR3y4pTvAZYgAKKQo8aDp5uF6925MedtbHKUacuey JGOa90oo5b6RpNo39iiUWfblVz+/4heV494mE7gF0osLUGXIggn/pqFf84JQuo+UId/z 2vtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=g7jUFWBxlvBEqq1quOiCvFi96EvwCZUtaqf3egOZBgw=; b=CHW6pfTGxWAHfVxbbhnVHp1KmYmzk6IgbPlsEcSw4pAf3ePHRw86ZfLxl82h15gCGT j7dZYHzJMioNOdm2ZImI2evAm1bat+/B1Dn095fPIRVkzDxHihaelW9CbZusah7IxhGg jM/Pc8QV3XFoCfNuNSYu7A+K4R0UVFEDBE242hwOjiW8ISRmrF0ATrBAu7sMB0LUvPnQ oIPWcFqB9F5D+07eATKSU6LxEGMyIKARgvmWYYETt3U9CC1H3z+MN55m14ZZG4Uxh6oz SY9/ORm2js9/5fcz/9TF20a423LCLPQKGcfQxFVrQafjGQ4rAQkgeuaLRfWRNdTRoUFu Sh7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=R8iOlcOV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id rm2-20020a17090b3ec200b001d2fe6d0a11si24018263pjb.176.2022.06.05.22.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:06:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=R8iOlcOV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7A00B134E36; Sun, 5 Jun 2022 21:15:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245338AbiFCPK0 (ORCPT + 99 others); Fri, 3 Jun 2022 11:10:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230486AbiFCPKZ (ORCPT ); Fri, 3 Jun 2022 11:10:25 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EDC7393FD for ; Fri, 3 Jun 2022 08:10:25 -0700 (PDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 253Dvmeu039165; Fri, 3 Jun 2022 15:10:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=g7jUFWBxlvBEqq1quOiCvFi96EvwCZUtaqf3egOZBgw=; b=R8iOlcOVS7fJjcbdzbv19n3ZO6onF0ufsfiUeyDTkVl0BBLBSUMGj3lxrk3RRWOyKsMV FoxqD7FcwSGhPtzRPoltucsByWGfozqaYdgBk+2clXwWqyCVOfmfkpJQVPhlh2LJI8CW SRbZ+qk9HTHtYkyznoExKJtDt09s80AuFgNEHkMdKmJgPh/gPXi5FDq4lcvM54tPIXy+ yOwKfIWqXGqlR/abeash4Wgb11w73cEUzFaXlTAcY5AAX5o/k/F+yEP/TUKunULDJBMv td+RZ9qk6ZWU+8TpqaunIRk1pzSPCGo0EG0Yeo8RKWnA43j2o/fHDdanazFmPdW12Rvz WQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gfkn69df9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Jun 2022 15:10:00 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 253F8QTZ039849; Fri, 3 Jun 2022 15:10:00 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gfkn69def-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Jun 2022 15:10:00 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 253F6DCq014972; Fri, 3 Jun 2022 15:09:57 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03fra.de.ibm.com with ESMTP id 3gbc97xhxj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Jun 2022 15:09:57 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 253F9t8L38207904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Jun 2022 15:09:55 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 213C242042; Fri, 3 Jun 2022 15:09:55 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A6BA342041; Fri, 3 Jun 2022 15:09:49 +0000 (GMT) Received: from [9.43.93.173] (unknown [9.43.93.173]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 3 Jun 2022 15:09:49 +0000 (GMT) Message-ID: <046c373a-f30b-091d-47a1-e28bfb7e9394@linux.ibm.com> Date: Fri, 3 Jun 2022 20:39:47 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [RFC PATCH v4 7/7] mm/demotion: Demote pages according to allocation fallback order Content-Language: en-US To: Ying Huang , linux-mm@kvack.org, akpm@linux-foundation.org Cc: Greg Thelen , Yang Shi , Davidlohr Bueso , Tim C Chen , 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 References: <20220527122528.129445-1-aneesh.kumar@linux.ibm.com> <20220527122528.129445-8-aneesh.kumar@linux.ibm.com> From: Aneesh Kumar K V In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 8x6etQlFsFBiMkGXOAXlYGd_HIYEx0EX X-Proofpoint-GUID: vXFrfR2MtraSKq6ABD5k3wf9zz8ThVPu Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-03_05,2022-06-03_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 bulkscore=0 impostorscore=0 phishscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030067 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 6/2/22 1:05 PM, Ying Huang wrote: > On Fri, 2022-05-27 at 17:55 +0530, Aneesh Kumar K.V wrote: >> From: Jagdish Gediya >> >> currently, a higher tier node can only be demoted to selected >> nodes on the next lower tier as defined by the demotion path, >> not any other node from any lower tier. This strict, hard-coded >> demotion order does not work in all use cases (e.g. some use cases >> may want to allow cross-socket demotion to another node in the same >> demotion tier as a fallback when the preferred demotion node is out >> of space). This demotion order is also inconsistent with the page >> allocation fallback order when all the nodes in a higher tier are >> out of space: The page allocation can fall back to any node from any >> lower tier, whereas the demotion order doesn't allow that currently. >> >> This patch adds support to get all the allowed demotion targets mask >> for node, also demote_page_list() function is modified to utilize this >> allowed node mask by filling it in migration_target_control structure >> before passing it to migrate_pages(). > ... >>   * Take pages on @demote_list and attempt to demote them to >>   * another node. Pages which are not demoted are left on >> @@ -1481,6 +1464,19 @@ static unsigned int demote_page_list(struct list_head *demote_pages, >>  { >>   int target_nid = next_demotion_node(pgdat->node_id); >>   unsigned int nr_succeeded; >> + nodemask_t allowed_mask; >> + >> + struct migration_target_control mtc = { >> + /* >> + * Allocate from 'node', or fail quickly and quietly. >> + * When this happens, 'page' will likely just be discarded >> + * instead of migrated. >> + */ >> + .gfp_mask = (GFP_HIGHUSER_MOVABLE & ~__GFP_RECLAIM) | __GFP_NOWARN | >> + __GFP_NOMEMALLOC | GFP_NOWAIT, >> + .nid = target_nid, >> + .nmask = &allowed_mask >> + }; > > IMHO, we should try to allocate from preferred node firstly (which will > kick kswapd of the preferred node if necessary). If failed, we will > fallback to all allowed node. > > As we discussed as follows, > > https://lore.kernel.org/lkml/69f2d063a15f8c4afb4688af7b7890f32af55391.camel@intel.com/ > > That is, something like below, > > static struct page *alloc_demote_page(struct page *page, unsigned long node) > { > struct page *page; > nodemask_t allowed_mask; > struct migration_target_control mtc = { > /* > * Allocate from 'node', or fail quickly and quietly. > * When this happens, 'page' will likely just be discarded > * instead of migrated. > */ > .gfp_mask = (GFP_HIGHUSER_MOVABLE & ~__GFP_RECLAIM) | > __GFP_THISNODE | __GFP_NOWARN | > __GFP_NOMEMALLOC | GFP_NOWAIT, > .nid = node > }; > > page = alloc_migration_target(page, (unsigned long)&mtc); > if (page) > return page; > > mtc.gfp_mask &= ~__GFP_THISNODE; > mtc.nmask = &allowed_mask; > > return alloc_migration_target(page, (unsigned long)&mtc); > } I skipped doing this in v5 because I was not sure this is really what we want. I guess we can do this as part of the change that is going to introduce the usage of memory policy for the allocation? -aneesh