Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1450461rdb; Tue, 30 Jan 2024 21:12:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0JLqs0dOAZUA34GnZcAvj6iwYJPWW2byIDvcUZxm41w4PdbHtmq2nqWJ66QZc6fPhbFad X-Received: by 2002:a05:6512:3f0a:b0:510:1b63:c63b with SMTP id y10-20020a0565123f0a00b005101b63c63bmr495931lfa.41.1706677971423; Tue, 30 Jan 2024 21:12:51 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWvT+iu/xL/Y6WRvmQzA95Z+2lUydGSh9DWEXIPpv7Cy/SBD4pgY78P4RYrqOyVxK5auPkQcp1M+GTPnLqidO46+e1AYi+5H1Z92xtifA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a2-20020a1709065f8200b00a3221a953e8si5358732eju.739.2024.01.30.21.12.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 21:12:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45761-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@memverge.com header.s=selector2 header.b="ugn1b+/E"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-45761-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45761-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=memverge.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 08E851F22FA3 for ; Wed, 31 Jan 2024 05:12:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6023C3D98B; Wed, 31 Jan 2024 05:12:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=memverge.com header.i=@memverge.com header.b="ugn1b+/E" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2124.outbound.protection.outlook.com [40.107.94.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C06733D548; Wed, 31 Jan 2024 05:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.124 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706677954; cv=fail; b=ub3cP1FctQHWXopYT209VhEgHrmXyNechRM4EGVrAuEa04N0jdNM/ZJHhsHdt9rZwHXVSOWTtPNVaLb6amjh+JxO5OhGsYSMWZDmj3GNdKrqDLZSp56G609H33//P8gmHASh3CnXW61Mx7CYJaipq28yNTGaFIssBH9Q8OvCKsg= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706677954; c=relaxed/simple; bh=Pa2GbEDS619nUEgdNXgkpvNVANqYDGOvAEzL0IItvDc=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=Wi155J/WBTUhdkaPEHCMgtAWtu1+7X7g6ttQ2wVe5UjFW7pSRmY9GSQnKnDOvwwFG+9G6L9BDfGcqjG9P9M1HCPANTdaQ9MjqidevMBtugiAsTKexMaOeCrjfW6PYtQcKV9YGbtQagT0C5PGle5YpCLWt0xdJZJ8vKWsfsw6qB4= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=memverge.com; spf=pass smtp.mailfrom=memverge.com; dkim=pass (1024-bit key) header.d=memverge.com header.i=@memverge.com header.b=ugn1b+/E; arc=fail smtp.client-ip=40.107.94.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=memverge.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=memverge.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WsqY2h+u/z9aRiuNJVLNxCGJ5po0BEoAVdP3YQRfAYk2dWswO5ZNEan2DX2bOaPN2JjolAwM9wxS5OmY+iYoH94b8oJExfO1CiYdbmm0F/6IJj1XkTxyloiJR/sHRwiUhbkAH7NfiQKVX3aWz81nb8WXJfM0EHFNZyeUyqBeHRjLXdk0N7vaS77XU4PULVrXd/FLhHMgVrvdtbkx8QRae+kSGWJeK7k3A0q+HvyOYVu2cCaozl/AKIsv2LGsJSEza5tus0sFcvGVDFRIlo2BKcDVqsfraB8J4T8iVTLnf/oOIwIGuw9x+k8G5C0c/on7ydVvfSWol06W/UBMZOHsqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yzy+08+X5nBwtfZjcfR/cB+0TAoxQzf92ItY0JBaz90=; b=DMAKegLl6C1QO3VS428XQP5h+30G+XbSV2laUTabi1B5aL1klnHh5c9QAu7170G4gYgHxinJV4wJxaaPi4FpJxWAvr8uNTK6ftlaGSkEhSk++4RD5LxCbE6R9piXNGRVNXVvb4tjCADeEAmp+jyhha0k/o5ChAZnSdwOp+I2h688XddFmra+9YHGSTuYExUEacIEr2FgQRCgiT5zfuhDFbgha/UE0tWjdrtJEtTo3HiVC8icvs/h3aR0ZLxgzGJ4FMRxNUC13Yuu+3HHUBAOVUn3H2W8T6iEz5QBashKzPwbKh54umohE0LD7gYQJwmULu+RMfh8Cqs+ewGDrc1ZsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=memverge.com; dmarc=pass action=none header.from=memverge.com; dkim=pass header.d=memverge.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=memverge.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yzy+08+X5nBwtfZjcfR/cB+0TAoxQzf92ItY0JBaz90=; b=ugn1b+/EUA41NEkn0fp/BoFoeooLv8ri6gZLPEU4OROgVJsu1y4P5/vKLS+/Nfj3C6LMFTF04n/rDIhELxqIvmjBxMoz3LYDGRMQ/Hv+lFAuZ5fSFNkglmMslPYSdQ9L8dc2erGpyEQOFb+5eKpGmNtsvtgCT/4SeRObtymaR9M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=memverge.com; Received: from SJ0PR17MB5512.namprd17.prod.outlook.com (2603:10b6:a03:394::19) by SJ0PR17MB6545.namprd17.prod.outlook.com (2603:10b6:a03:4e2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.34; Wed, 31 Jan 2024 05:12:29 +0000 Received: from SJ0PR17MB5512.namprd17.prod.outlook.com ([fe80::7a04:dc86:2799:2f15]) by SJ0PR17MB5512.namprd17.prod.outlook.com ([fe80::7a04:dc86:2799:2f15%5]) with mapi id 15.20.7228.029; Wed, 31 Jan 2024 05:12:29 +0000 Date: Wed, 31 Jan 2024 00:12:24 -0500 From: Gregory Price To: Gregory Price Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, corbet@lwn.net, akpm@linux-foundation.org, honggyu.kim@sk.com, rakie.kim@sk.com, hyeongtak.ji@sk.com, mhocko@kernel.org, ying.huang@intel.com, vtavarespetr@micron.com, jgroves@micron.com, ravis.opensrc@micron.com, sthanneeru@micron.com, emirakhur@micron.com, Hasan.Maruf@amd.com, seungjun.ha@samsung.com, hannes@cmpxchg.org, dan.j.williams@intel.com, Srinivasulu Thanneeru Subject: Re: [PATCH v4 3/3] mm/mempolicy: introduce MPOL_WEIGHTED_INTERLEAVE for weighted interleaving Message-ID: References: <20240130182046.74278-1-gregory.price@memverge.com> <20240130182046.74278-4-gregory.price@memverge.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240130182046.74278-4-gregory.price@memverge.com> X-ClientProxiedBy: BYAPR01CA0032.prod.exchangelabs.com (2603:10b6:a02:80::45) To SJ0PR17MB5512.namprd17.prod.outlook.com (2603:10b6:a03:394::19) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR17MB5512:EE_|SJ0PR17MB6545:EE_ X-MS-Office365-Filtering-Correlation-Id: 300ffd92-869a-4cdb-7f9e-08dc221b38c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fwt57qkiFFw65TQQDi9XwnDOyJr/4HfNiAGlVv6WRp1gzvcFtrRbkufpdr7aYwOjZdm1jEMMPVH0UOR8ZVFbC1bqi6jaPemQCXiR+g9Em6LxXryxwweNafXHW1MczoRixbQc9Iq4blort3ZiE9aljZTZ2Yg+BVK8os2dMExaeMnU9LJ/B8PCX634oo172wxgGrHmW/SdO2BKgxIhH/XrAqf2bLjxE7J6gmfXRKKTWYDIWLqEWFtTZCUjnd0E/jP15diKcMk6spJP6LS0/TQDePKtmgf/PdVaADmlOLMF7wmujQRf7GKaXIgbOu6cqyrzSDyoc9myktmk21amMOpF5kB1HHGKNWM8q6tNCdeA5Vu7ItRveKHKQr37fBt13ZZuZpjjU6+KOtAYfIj5ThVyDXivxCZA6ENZJlMz0Qsl855rmn22yHtlhViVVWGLQ70Qi3M56/O/AJJKz8klaPPY+pZXjGe+Ur6yQRBXHH7PoMjrfJDKTzbBFD8JQSEaKeNRsS88kM2H5+9kPAN2E/ch2Zyj5br96j9QS9Vyjn2tOyF0/gk+RdKIqj3MD+NDVRgyunZkuBjSqxgIfOdI8gfUVSwoRV+Dek525vSPbAlN0Cwnw7fGVTzVTQXK4dczzaog X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR17MB5512.namprd17.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39840400004)(396003)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(8936002)(8676002)(4326008)(7416002)(2906002)(44832011)(5660300002)(6486002)(86362001)(316002)(6916009)(66556008)(66476007)(66946007)(36756003)(38100700002)(6512007)(6506007)(478600001)(6666004)(2616005)(83380400001)(26005)(41300700001)(16393002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?HPbAhSkvl212xHi2ccUmrZTOnxxlLdtv/4zn576q1csZf0L/4TbX18f92Sk9?= =?us-ascii?Q?TVDgpCgWq6RBP/XMqPODOjNHJbyYbssvKxIhWlvlXGt+zUGJkksDIveSY8Qd?= =?us-ascii?Q?+sQJFjqd+idFWcNiWve1Z+E416gTFKV/JlaX0xO2AKXV8CYl/R21Lp+3KdMP?= =?us-ascii?Q?h8PKGs0E//CSbXI8OiQb/zZV7sbzzUmKkDQIHnpMmOofgIyRfvZo6D2Tn3uZ?= =?us-ascii?Q?xft20U9unyYhMeEP+iB5l6zFD/TFjmCdkmnnnWeC6PniGS3WVu3psnE+ptpc?= =?us-ascii?Q?zg5NxQ3QfLPqW2gyHihbyK97M4gxTnQCQOZmLjgs/H7z4izejihcYBip7hZF?= =?us-ascii?Q?+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GKCTT2Q2JlwgwoPlsm?= =?us-ascii?Q?2CxJghcdyI/UYvaFx62wE9G4ODc253a/8uLpWrRlwurn2b9GgsSjXfdJeIAk?= =?us-ascii?Q?vPbW7b1ASE3U/ir92qeImfk5X2bNli17C16+xZiKnpGImIpK2lyecgxZwkLa?= =?us-ascii?Q?SAVx8IymJF+pRKaDTpnYt9wvUvbAWJ934rv+vbJLCP5zEzSlY4hs5hYUVc/E?= =?us-ascii?Q?xOE74ALsoTtw7UfksZIHWxI+aAGMZx78HF57Xx0tw8oucS7GW+jOUva7B/OV?= =?us-ascii?Q?usPK8tQRzRMY6YrLKmQ3nEVjCaLwTDDLJO6Y0IZqfSf5Mv8VPIX/zBVwU2Hq?= =?us-ascii?Q?Ublr2hUJw2KNOhm0l3VL4J7zVrjfZ1Nfq6rhBUAdcSlmFOoNcEsIzwSbG5/T?= =?us-ascii?Q?EA=3D=3D?= X-OriginatorOrg: memverge.com X-MS-Exchange-CrossTenant-Network-Message-Id: 300ffd92-869a-4cdb-7f9e-08dc221b38c4 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR17MB5512.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2024 05:12:29.2807 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5c90cb59-37e7-4c81-9c07-00473d5fb682 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bMKIXlFUq2MdZNrWoPp+n0uRXYOPtozAPyNnm+haqdluevK5a0rEiPsjLZCEg/36T6XvL1mV9730e0uCHk0JCNDKd/K37fD0mnxUrGgzLSQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR17MB6545 On Tue, Jan 30, 2024 at 01:20:46PM -0500, Gregory Price wrote: > + /* Continue allocating from most recent node and adjust the nr_pages */ > + node = me->il_prev; > + weight = me->il_weight; > + if (weight && node_isset(node, nodes)) { > + node_pages = min(rem_pages, weight); > + nr_allocated = __alloc_pages_bulk(gfp, node, NULL, node_pages, > + NULL, page_array); > + page_array += nr_allocated; > + total_allocated += nr_allocated; > + /* if that's all the pages, no need to interleave */ > + if (rem_pages < weight) { > + /* stay on current node, adjust il_weight */ > + me->il_weight -= rem_pages; > + return total_allocated; > + } else if (rem_pages == weight) { > + /* move to next node / weight */ > + me->il_prev = next_node_in(node, nodes); > + me->il_weight = get_il_weight(next_node); Sigh, I managed to miss a small update that killed next_node in favor of operating directly on il_prev. Can you squash this fix into the patch? Otherwise I can submit a separate patch. ~Gregory diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 7cd92f4ec0d7..2c1aef8eab70 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2382,7 +2382,7 @@ static unsigned long alloc_pages_bulk_array_weighted_interleave(gfp_t gfp, unsigned int weight_total = 0; unsigned long rem_pages = nr_pages; nodemask_t nodes; - int nnodes, node, next_node; + int nnodes, node; int resume_node = MAX_NUMNODES - 1; u8 resume_weight = 0; int prev_node; @@ -2412,7 +2412,7 @@ static unsigned long alloc_pages_bulk_array_weighted_interleave(gfp_t gfp, } else if (rem_pages == weight) { /* move to next node / weight */ me->il_prev = next_node_in(node, nodes); - me->il_weight = get_il_weight(next_node); + me->il_weight = get_il_weight(me->il_prev); return total_allocated; } /* Otherwise we adjust remaining pages, continue from there */