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 31937C433EF for ; Fri, 15 Jul 2022 07:22:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 865E39401CF; Fri, 15 Jul 2022 03:22:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8142D9401A5; Fri, 15 Jul 2022 03:22:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DC489401CF; Fri, 15 Jul 2022 03:22:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5F50A9401A5 for ; Fri, 15 Jul 2022 03:22:18 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 33FED3581F for ; Fri, 15 Jul 2022 07:22:18 +0000 (UTC) X-FDA: 79688490756.31.7D21A03 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf06.hostedemail.com (Postfix) with ESMTP id B6612180039 for ; Fri, 15 Jul 2022 07:22:17 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26F6hoCb004034; Fri, 15 Jul 2022 07:22:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : in-reply-to : references : date : message-id : mime-version : content-type; s=pp1; bh=+czgEbTszIZgJ23+VtNlz6CBVsIjEr9wjSrV/qdWzo0=; b=Gqav5gnHE6Od5rGJYBBw9AwT2oIRHxMX+ePRfYm/WMIyaaegoYMx3p9r2wkSFNHcVSiW XLvgzvAwwSS7x5EeJLEES91slKiGqVJ70SeeXS4iSew6GDT5xg0E/6nYpha9FtJ66pOw 9V3EEcoWetBrOrocK9lYx59LPx7mw5kCm6eSlimpq7IphqTDm62zFOJTfvvnEHqKj2NA qUzpnPPrl5JQDA18xY1DyQj7A1XztoYK9Wihu/DjZlp0DMEKAYKo8J4zk2Yk7XksJRTj pXF2ZiEYCduldSxO08sI1Hg5dJNVIahFH1609bzLEZ5DFuPHXEuwHLVwL/i76uhHCAYA Aw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hb37jgq8s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Jul 2022 07:22:01 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26F78ckI004509; Fri, 15 Jul 2022 07:22:01 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hb37jgq8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Jul 2022 07:22:01 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26F7JwNq028579; Fri, 15 Jul 2022 07:22:00 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma04wdc.us.ibm.com with ESMTP id 3h71a9ygpq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Jul 2022 07:22:00 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26F7LxrY50463120 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Jul 2022 07:21:59 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6CFB28059; Fri, 15 Jul 2022 07:21:59 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A4E628060; Fri, 15 Jul 2022 07:21:54 +0000 (GMT) Received: from skywalker.linux.ibm.com (unknown [9.43.84.38]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 15 Jul 2022 07:21:54 +0000 (GMT) X-Mailer: emacs 29.0.50 (via feedmail 11-beta-1 I) From: "Aneesh Kumar K.V" To: Alistair Popple Cc: linux-mm@kvack.org, akpm@linux-foundation.org, Wei Xu , Huang Ying , Yang Shi , Davidlohr Bueso , Tim C Chen , Michal Hocko , Linux Kernel Mailing List , Hesham Almatary , Dave Hansen , Jonathan Cameron , Dan Williams , Johannes Weiner , jvgediya.oss@gmail.com Subject: Re: [PATCH v9 5/8] mm/demotion: Build demotion targets based on explicit memory tiers In-Reply-To: <87cze6apeo.fsf@nvdebian.thelocal> References: <20220714045351.434957-1-aneesh.kumar@linux.ibm.com> <20220714045351.434957-6-aneesh.kumar@linux.ibm.com> <87cze6apeo.fsf@nvdebian.thelocal> Date: Fri, 15 Jul 2022 12:51:51 +0530 Message-ID: <87zghau9gw.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: tE9xHqtNZlpqTx1u4k4IPXjuYeofyL7q X-Proofpoint-ORIG-GUID: qvo2Y_mnWp8zdFdenqJ_expB0aU2f8_l X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-15_02,2022-07-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 malwarescore=0 impostorscore=0 mlxlogscore=919 adultscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207150029 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657869737; 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=+czgEbTszIZgJ23+VtNlz6CBVsIjEr9wjSrV/qdWzo0=; b=CfHw4bDw+vMIrvYTxqWMEYuhSHIpBUwqXoDaAtz26BrWX+F3DuhI6s3F1BEIC7tWdJ6Hjw +dmuVI/Xs5gidsS1JiLMKb+dFwI0VPuYRK+Aj2jqhOzFiCcnNCtOOuJUdfyiv3Uju24gyD uhWL/PLiO4JM+OB1+jyMl4xFBDu9sco= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657869737; a=rsa-sha256; cv=none; b=PoH+rKvIu6PqDx9Hkk56FxPR9shPB2TopL1jtKtN8wT3QJTmmKs5O1AEDJRZAndOp/ULDd VKbxPneZ6GvejZIAGyqqcbRLyPgrsq5qK59ZRNAyVlcMs0sKR50K67nbevTpCCLkaWLfd4 QFfrGoyX7NwIBHTiU649TeAQhmOfuUo= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Gqav5gnH; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf06.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com X-Stat-Signature: 8gctcunyiwm6gyb14qfc97kwqjurj3sc X-Rspamd-Queue-Id: B6612180039 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Gqav5gnH; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf06.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1657869737-182159 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: Alistair Popple writes: .... > + */ >> +static void establish_migration_targets(void) >> +{ >> + struct memory_tier *memtier; >> + struct demotion_nodes *nd; >> + int target = NUMA_NO_NODE, node; >> + int distance, best_distance; >> + nodemask_t used; >> + >> + if (!node_demotion || !IS_ENABLED(CONFIG_MIGRATION)) > > Does it make sense to include the memory tiering/demotion code if > CONFIG_MIGRATION isn't enabled? From what I can tell none of the > information established here is used if CONFIG_MIGRATION isn't enabled, > so it would be better to remove the IS_ENABLED checks and not include > the code at all. We use the same function/codepath for updating top_tier details. We would want to get node_is_toptier() to work even with CONFIG_MIGRATION disabled? > >> + return; >> + >> + disable_all_migrate_targets(); >> + >> + for_each_node_state(node, N_MEMORY) { >> + best_distance = -1; >> + nd = &node_demotion[node]; >> + >> + memtier = __node_get_memory_tier(node); >> + if (!memtier || list_is_last(&memtier->list, &memory_tiers)) >> + continue; >> + /* >> + * Get the next memtier to find the demotion node list. >> + */ >> + memtier = list_next_entry(memtier, list); >> + >> + /* >> + * find_next_best_node, use 'used' nodemask as a skip list. >> + * Add all memory nodes except the selected memory tier >> + * nodelist to skip list so that we find the best node from the >> + * memtier nodelist. >> + */ >> + nodes_andnot(used, node_states[N_MEMORY], memtier->nodelist); >> + >> + /* >> + * Find all the nodes in the memory tier node list of same best distance. >> + * add them to the preferred mask. We randomly select between nodes >> + * in the preferred mask when allocating pages during demotion. >> + */ >> + do { >> + target = find_next_best_node(node, &used); >> + if (target == NUMA_NO_NODE) >> + break; >> + >> + distance = node_distance(node, target); >> + if (distance == best_distance || best_distance == -1) { >> + best_distance = distance; >> + node_set(target, nd->preferred); >> + } else { >> + break; >> + } >> + } while (1); >> + } >> +} >> + ..... -aneesh