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 041B9C282E5 for ; Wed, 5 Mar 2025 18:54:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0E50280019; Wed, 5 Mar 2025 13:53:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A96FB280002; Wed, 5 Mar 2025 13:53:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EE26280019; Wed, 5 Mar 2025 13:53:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5EF96280002 for ; Wed, 5 Mar 2025 13:53:57 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5EB1D120864 for ; Wed, 5 Mar 2025 16:28:36 +0000 (UTC) X-FDA: 83188030632.11.2C6CDB2 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf21.hostedemail.com (Postfix) with ESMTP id 80C011C0005 for ; Wed, 5 Mar 2025 16:28:34 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=neANI5V9; spf=pass (imf21.hostedemail.com: domain of joshua.hahnjy@gmail.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=joshua.hahnjy@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741192114; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3kXO6L+kuZ25c+P5TosdrwsFHxjeYxKmuRYQ7Ze4zvU=; b=a8ALXwGAzFcatt9o0LgTCVeMvlHIOatrMN9cyQHvPwiaiYZzpRBjYKM8M7xPPDNU6pZQgq tBqA9jgHmsDIAsm59cWnrG+qcyaohn0/99Ub08fQ5Nj0aipVMK/XI+3YrodV971Af04LHq XdSbiFHEdxQn+dp/HoO/TsTWJ+uIbEg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=neANI5V9; spf=pass (imf21.hostedemail.com: domain of joshua.hahnjy@gmail.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=joshua.hahnjy@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741192114; a=rsa-sha256; cv=none; b=GtBaZ2PoWcC3oJKD9Tj23DPA3C4pXHD0rm9xHwEhwgUdmDNpiR+6uDCInoUR9rQ1Y8TOKK jl9jDgDZCgQL3fIkacjZsYqEjBf++QYlPWrncO3WR3/3cET4NKkYaHg6bhpBTyl8zkOqWs Yfyp5jxl3FODC56RKz628SBO1lh6zZ8= Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6e89ccbbaa9so47759736d6.2 for ; Wed, 05 Mar 2025 08:28:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741192113; x=1741796913; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3kXO6L+kuZ25c+P5TosdrwsFHxjeYxKmuRYQ7Ze4zvU=; b=neANI5V9qplW+w2sqb8GFOSfKBnMDnhoD4fi8rBx8Yz1R0OMjF5E5+f8/lVRlK+N4+ 325ROIVVKHMsTVCUcPtEEe8QRhTu1pueqvVwGXHXEv0pUYz4GZb/IrvDPa+uEHFkyaD5 J8TC7Biw70zwHLJOSJRV5eWruCgX2ZYv3gJwTRRFj2EQHMiUrjbHksv1IGwAwKwZEvRs O6rJaNwiF0tQYj69+puYEgB2tD1KxpjxsJkXjvIDVP/szd1tPSjsQdcIDRFCgCJKtEjd 4D/iM3wsf94lIgDIrPx5iTXDd9A7i3/M+hSnW6hh8x34+fg49Xtp5r5BxuZQBxgoVtBo 4UAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741192113; x=1741796913; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3kXO6L+kuZ25c+P5TosdrwsFHxjeYxKmuRYQ7Ze4zvU=; b=BI0970/gTOWlyK/V2e+1n8m57bR77/H0ZTFRdjKUfiAKZFlplKqm9Xva335xxZEUvt EIUff9Tm7bhl3pC9XuWQatru908T/Oc98Tr6vdismGATJXbVny8Bk8PfpPIeaFBOjRCz 9q7nMvM9h7aIRhH0EyZCIkqUmQPKXlzQ+hO3GTQVdLhjIdaBMMyoa7OeXPpQLzvM2CwC pJHKJwwdyGl6Vl9toWNR2h1MWV6ZJpCCsw0zHcOY/74IKpxMUgThxJaX3+raBvaF9bF4 ZeyUI6n0iuhlMfTTYFkS+tTyCIF/XKKUhhrQExY8i90IAZaWTlFoNDtxQ4f2wZAabkll I/rg== X-Forwarded-Encrypted: i=1; AJvYcCUf1H82THf8OQSnFQ/rrKUWV29Havd3vhECaznYqgkOvygrL0n/H9KY41dlFeD7RWUtcdK0qxrORQ==@kvack.org X-Gm-Message-State: AOJu0Ywm9fYTxJeO26INVEFThLqnGr+/gM0JtpNXh57ww4JHme3JVons 4idq6i5bwWsKMdS8FhnoqZKsntXY6gukcqq07wBZfEwGUhXNixSZ X-Gm-Gg: ASbGnct4pxtsLcOYvkOCVzovjYqRqWeV3WanD+iQ3iUFjuU/knUMlTuTYcx7cmNfAkn TJrW5qHEe3RCR3m7eooSdXz/FBZoOepw1LBPt1b75YJ4wez9quCKTRbiWEbmQJ5N742C3yzGpoj Sd42ozxc1lOTigfVvuMVYrM73WpcwwgJbyqUvd58FUFze41uux2xkhP3hEkyYXs+rDI3GrIyVHr m8xZCeGj+Ez7phNfY4N+mb2FrCdSNy0B66tM055ErcjnFQ/YlekfuJC4fSotwaM1XdjcpsyC/Oh ka0k1MjtVjdJ+0olQkwfvZ5oMGT0ugP0Awz8Eg1/xWlYoy4jTGHQdBZKGG2aN86E5YIknDULh3D SwA== X-Google-Smtp-Source: AGHT+IGITUNzs6gnChE+1sYvZx5Pu2AD6l1jML7iarWBxHik8iHbPlfbOGKzFOMTbsg6z5D70bG5tg== X-Received: by 2002:a05:6214:e87:b0:6d8:ada3:26c9 with SMTP id 6a1803df08f44-6e8e6ccf943mr61318836d6.10.1741192113561; Wed, 05 Mar 2025 08:28:33 -0800 (PST) Received: from joshuahahn-mbp.thefacebook.com ([2620:10d:c091:500::7:2424]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-474febab252sm24470141cf.3.2025.03.05.08.28.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 05 Mar 2025 08:28:32 -0800 (PST) From: Joshua Hahn To: Yunjeong Mun Cc: honggyu.kim@sk.com, gregkh@linuxfoundation.org, rakie.kim@sk.com, akpm@linux-foundation.org, rafael@kernel.org, lenb@kernel.org, dan.j.williams@intel.com, Jonathan.Cameron@huawei.com, dave.jiang@intel.com, horen.chuang@linux.dev, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, kernel-team@meta.com, kernel_team@skhynix.com Subject: Re: [PATCH 1/2 v6] mm/mempolicy: Weighted Interleave Auto-tuning Date: Wed, 5 Mar 2025 11:28:29 -0500 Message-Id: <20250305162829.86650-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250305094918.968-1-yunjeong.mun@sk.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 80C011C0005 X-Stat-Signature: 8g38r4mhtusoj7tsyggqpt1hanwm39im X-HE-Tag: 1741192114-915462 X-HE-Meta: U2FsdGVkX1+s8m5c9MzOZbqyN86sTf8rESlO98RAh8nDx+xT1o0tO8NaYUWoduSAEHnP6jH9HHYXAXlxYh7qQfaGCvlvR9Vh45MuPwT6qpjfWmk8e1PUvgc0++B3C+1gkgyKPuELcqSnb8CqA5/DHnYbVy36ShFFCixCrm3k4UZC/qFNeJvaRwEXeJ5klRLKaXPSYbgRGFhF7SfOWDvhBxcc7PTb2mpzM9c6ggu3lfcnBE/IfFuZbV3/micZRInpGe2QgKMH65BMJzWeCpy/7kDnAGzRqaoZfDmFYhSx1leyrbUZbTOKOIUxyWm9X5FFFUtgsFXmem15mhAWKw82xsebo/PIOzpRbqJm50F/WC1gykTk5wagZW4DjNQonNhND5Q24eYkLiEcHiLko+eRbtYf9TcjArRgRRxFxvQW8wYiCrzzM3wVcCM9db5zyZ08vFbIIdjF4zHRNfoofaY/BFpi3/MFA2Ea4WdCE0AOl44zfK5OBUY+og/xHxYxMlERJYZois2Rr4jt+IOyvn13c3aHstRV8jFveNvLQaSkk5r010WE3bMENZyQ+kncqnnpGQSHjuJCQDIrxvNz0LuhgaWfWlPiK/MGCA6uKZjqOtuwipgRIRLRDUaudP/sC4C/K7Qs91cJgRu7cC+NPpHZ72tlhQ+1sW4wYezyYJ1PSKgVKn7EOWVJVBaBhd+XMscrJBashRcXN0mPEfBMP21Ck5qDwO6VBuaPDkLb0zs7978JBK/v89WbE4ZKKej4Jq02C6w+K3YP6tP3fMeBTfJ9+22AxX7UgE1z4qTV7KkDDpCknM7fAY2hsG3smNVZwDP/66MtGTKZtLDP/AZalGX/OgVAxXUhfRApTZY/CvIH5P4XlDcGiEGG0zlQCikWw+GrwKZgPVo7mWbFiBeHRSg8CrVISFQ1D5rZ8EYgdH0A5JUeTzYU3BEP8yrhWpMpz+nacmYC0FGClCXQKoKduNR XCAxmX5A ESbX/ROb956q9CkVNGYcgk8anCEcaTlauVbvfZzX7T+J39zo9xyGsuASmWjdvrdpjPKmfcaWsd5jyIMiP//d5eNtvsFgRBhBGAIFue43XUX2QKThk4f/RvYiXYwySCnNRbpqI9HEYWTLwSS0NyT9lXL2u8IDnLFol2rLQbRTXmK5pC90h6SGds2uwkW4qe33VmhB01ElCsihc4Iic9rPMqqbDTJ1F4BPq/ToDvaDU8JNTqZkVluXhOg8BAjs0/Suk0Jw600o6jaNxEBCJ1QWqmA8tacNOz7l9uY8OhysioP66ygG7tKKNX55myIuVePMJXvapUtKD7JEaYi5v0SS83hj3WlQWRg0B3gFaaDjJKPn1IAp+Hyh+Tef3cQ7qdOQRuHsVJzvX4PwR4JE3Vx/zwfdbPmDX4BOeR+5C1+qEu0U4DxfyU+Merxp33nr6qGpgDy7+Cne3xkY6KN6+HR0NMnspRKO++5Pg1xyod+Te8unhKoKVKRXWUu/Oikhgqj2P1GuDWzTG+OvtPBo= 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: List-Subscribe: List-Unsubscribe: Hi Yunjeong, On Wed, 5 Mar 2025 18:49:11 +0900 Yunjeong Mun wrote: > Hi Joshua, thanks for reviewing my patch and for your kind explanation. [...snip...] > > > > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > > > > index 50cbb7c047fa..65a7e2baf161 100644 > > > > --- a/mm/mempolicy.c > > > > +++ b/mm/mempolicy.c > > > > @@ -176,47 +176,22 @@ static u8 get_il_weight(int node) > > > > static void reduce_interleave_weights(unsigned int *bw, u8 *new_iw) > > > > { > > > > u64 sum_bw = 0; > > > > - unsigned int cast_sum_bw, sum_iw = 0; > > > > - unsigned int scaling_factor = 1, iw_gcd = 1; > > > > + unsigned int scaling_factor = 1, iw_gcd = 0; > > > > int nid; > > > > > > > > /* Recalculate the bandwidth distribution given the new info */ > > > > for_each_node_state(nid, N_MEMORY) > > > > sum_bw += bw[nid]; > > > > > > > > - for (nid = 0; nid < nr_node_ids; nid++) { > > > > [...snip...] > > ^^^^^^^^^^^^ > > When I was originally writing the response, I missed reviewing the contents > > inside this snipped section, which looks like this: > > if (!node_state(nid, N_MEMORY)) { > > new_iw[nid] = 1; > > continue; > > } > > I introduced this check in v6 because without this, we end up with the > > possibility of memoryless nodes having a 0 in the table, which can lead to some > > problems down the line (e.g. div by 0 in alloc_pages_bulk_weighted_interleave). > > To prevent division by 0 errors, how about setting new_iw to 1 when it is first > created, instead of setting it in the reduce function? I think this makes sense. The original motivation for including it in reduce_interleave_weights is because this function is usually called on newly allocated tables, so I thought I would just combine the functionality of initializing the table and reducing weights into one function. Howver, I now see that there are actually a few spots when either a table is initialized but this function isn't called, or when an already-initialized table is given to this function. The other rationale was that it seems a bit silly to go through and set all weights to 1, and then immediately overwrite them with the reduced interleave weights. With that said, none of this code is in any critical section, I'm sure that going through one more iteration and setting the weights to 1 is not unreasonable. [...snip...] > > > > Respectfully, I would prefer to write my own version that takes your > > suggestion, as opposed to applying this patch directly on top of mine so that > > we do not introduce the build error or the potential div0. However, v7 will > > include your suggestion, so it will go through only one loop as opposed to two. > > Thanks for considering my suggestion. I look forward to the v7. > > Best regards, > Yunjeong Thank you again for your suggestions, Yunjeong! I'll re-write the code to incorporate them in v7. I hope you have a great day! Joshua Sent using hkml (https://github.com/sjp38/hackermail)