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 A7C36C02198 for ; Fri, 14 Feb 2025 15:46:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FFFD280005; Fri, 14 Feb 2025 10:46:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B03D6B0095; Fri, 14 Feb 2025 10:46:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 277B5280005; Fri, 14 Feb 2025 10:46:05 -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 0831A6B0093 for ; Fri, 14 Feb 2025 10:46:05 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 48365A05C5 for ; Fri, 14 Feb 2025 15:46:04 +0000 (UTC) X-FDA: 83118976248.06.3F9033F Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by imf02.hostedemail.com (Postfix) with ESMTP id E34838001D for ; Fri, 14 Feb 2025 15:46:01 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cKIRibFV; spf=pass (imf02.hostedemail.com: domain of joshua.hahnjy@gmail.com designates 209.85.219.172 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=1739547962; 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=ycd2hQRX4+MoV0caObCZeDE/nlrKiGekQLF9H7HPZGc=; b=ezXS1YvYkXsvrYenBsGhRjSVb3vw6CgbnYLWMBiDS+XyyGi8bLEkXE7DFwplUkwT/Q8xHY 0ao2ZOOYV2JkqGdQDlTMctDHoSnWr3KYCSqqCH5dNEjsM9mstuP8Sh99Kz7O/jB6PHIDCc 3hNRqwZHlqql0BBu57zz0ZwO9yVT8iU= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cKIRibFV; spf=pass (imf02.hostedemail.com: domain of joshua.hahnjy@gmail.com designates 209.85.219.172 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=1739547962; a=rsa-sha256; cv=none; b=0gLRleGxTtc9duFgs1fRqOnGvtae1bniiHJ00Yk2c19E2Nnu4kcYKH8KwtVxgKAv/VQ9ME 0zyKO3h4XsrXGFxYo/FcGWJO+u0wraosVOe7x+3pxlcB+lD1WOVUAdC5c28lG39dC3k3rb 70VMhqyQIsJyl3Cm/lTa/q3aIKFEpWs= Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-e5dad00b2e6so1769965276.3 for ; Fri, 14 Feb 2025 07:46:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739547960; x=1740152760; 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=ycd2hQRX4+MoV0caObCZeDE/nlrKiGekQLF9H7HPZGc=; b=cKIRibFVOV0SMhGHfk+mEQHCaQHhQWAzN7lxp2ztupdxJSr0s8+eXijEvlwh7Al8YW 3a55YJC9dOd030mGrbwTiWToKe5/w0N2otqj951TXGeAazdsV1Cs2Af5hdqc7WgcxaFq OqRCkPh0xRP3xQSRwZoJcPiJJI6QYx5dgYCwl9hVG27trgc8JU8j7UX1ngpcxjfGOW/c XNeCGpLGk+u5QFsW2O1Ph1KGn0cXvvShPWubhO0kgVYPf0HeA/0VLC4+6Zyj0NbzvKZ6 qLPOD+i/7ehDEsrAuEn6bneEsK5f93bj80m0cea2M56iYBzOIcHomLZ4roi2NSnroKR8 gEhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739547960; x=1740152760; 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=ycd2hQRX4+MoV0caObCZeDE/nlrKiGekQLF9H7HPZGc=; b=aZmyJCD5ffUb5Y56u2Gf3HgmgsfDUwzW+GHdFmjXpP804Dk1oYt85KG9kUCDGzhg3D e5fwiX7lEkDJP4oBb3ba9YNYLhga6rjwmcbALHkr/zc7hx0IVS/CDQeOZ62ZXsAW63+l FsfNXwt1Cs3UOSoG0ZtUDh4d/ZVRujHimL+nuEHcvda4RNP97A8KeswUbymEIO1/FDQx sQHnr2gALUjgYAPNBn6FdcvKt8l/GoBLUz7la5iRhudfqNBUn92HiMz490KS3NMcXTm/ myv5x0m1KneyaTg7wYZRjJ5qi0m/CTvbGR0+OBvaRkvh6ycWSfhoqxALiQhM+aeksSmC wgmw== X-Forwarded-Encrypted: i=1; AJvYcCW6uRemA4VGfUv8WGJ96e4Dxmdcb3pZ/QRDW2J5eh7fVEjzRx/86aJ4zb4bLQ0wCDyETWat83LhNg==@kvack.org X-Gm-Message-State: AOJu0Yx6K5Vh5TOp3+VgMZoQKCCrUHyXdBOiPGQsU6v+LdVCUAgVJOiZ 0RT5fXvQE33+8hZHRvoe8RDpj30GkZlkDbDLXxkxjRf77lS0nK+1 X-Gm-Gg: ASbGncskfmlcVFW0fAQnv8Osk0sdKzJRgnTDpwGnNjBqB0lX+6rK4OwKp1vCP+cu8qh l7ZtC4jvlYYqn5928fOjHo/HSEg/QygY1OQjG3+s3Y/7FZnnSjmu9LtT18QTBVD75narCVVbnXJ 6j/newvaChuEIncxIjcdKVW2QafpAsIX4Fr3yQW9jkJxEGiaZuK95JQwfwD16FvzGkkF2y2RJ6R H2UIour2hCH7tWF0m7YAlZk7ksZTRBFR5rYZv72dJiMo4ju8oKVQkCd+rNrU5KXR0tDzLMhP85O bfJU1fuOAS8NMHc= X-Google-Smtp-Source: AGHT+IEbhVggH7lAbaMjzwEbOSlqEqdNkutZljo10EJI1cHWpmYtYE8XuonJl2V4uCPDhcB9pw/c2Q== X-Received: by 2002:a05:6902:f0e:b0:e5d:a785:464 with SMTP id 3f1490d57ef6-e5da7850564mr5151137276.18.1739547959974; Fri, 14 Feb 2025 07:45:59 -0800 (PST) Received: from localhost ([2a03:2880:25ff:72::]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5dadb6d819sm1085360276.0.2025.02.14.07.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 07:45:59 -0800 (PST) From: Joshua Hahn To: "Huang, Ying" Cc: gourry@gourry.net, hyeonggon.yoo@sk.com, honggyu.kim@sk.com, akpm@linux-foundation.org, rafael@kernel.org, lenb@kernel.org, gregkh@linuxfoundation.org, rakie.kim@sk.com, dan.j.williams@intel.com, Jonathan.Cameron@huawei.com, dave.jiang@intel.com, horen.chuang@linux.dev, hannes@cmpxchg.org, linux-kernel@vger.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, kernel-team@meta.com Subject: Re: [PATCH v5] mm/mempolicy: Weighted Interleave Auto-tuning Date: Fri, 14 Feb 2025 07:45:48 -0800 Message-ID: <20250214154557.329912-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <87tt8y1vem.fsf@DESKTOP-5N7EMDA> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-R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8zCct k2A5WnCS 0EJaO7KM6jtwf+J0D83TkP9KMvqOpM28wTxp7oXiMvaPCMwAylnI0YNe3QfSbZAMyhQ/1o4QTgF6Pyr104Tt2XndVsLT0KT7b/5v7h2wWd8d4gA+dh5KVzJPBOnLEcNQWLV+4qYsM0+2bBiRRyuJ+jG5g30zwvsADA/vSIgT/kT0BRkFV5itW+Hli75hAdT4qkN4pypediKjUpKKtKtY7Tlipde+SEOxRYJJ3A9q3wnxwwyrJywv4jNdBTitE1zqup+oQWtu088KLYJd4i7iLpTZ7EJLRh5W+kiiYZDhtvH4DFIjjXytDgF3IqFuVHvxlEUQJtMsYqckgBMcqujbpswLLxjSJHi/9ul5UcGFL1g+JqpCFiahLFeC5kK2Q8GVKhKaohdWFD3Mp9PK16RJTm68q8h+pgM/a+iqjQ2trBTCPGbCbrWBRfQtyj3qYQZUzmze1ZiC6/89poa1Q0j99cq/Ocsv1mGOEOLo3AxiXxrAD/6QXPkgnu6jfQIqG5fSOAKS1 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: On Thu, 13 Feb 2025 09:32:49 +0800 "Huang, Ying" wrote: > Joshua Hahn writes: > > > On Wed, 12 Feb 2025 10:49:32 +0800 "Huang, Ying" wrote: > > > >> Hi, Joshua, > >> [...snip...] > >> > + weighted_interleave_auto = false; > >> > + return count; > >> > + } else if (!sysfs_streq(buf, "Y") && !sysfs_streq(buf, "1")) { > >> > + return -EINVAL; > >> > + } > >> > + > >> > + new_iw = kcalloc(nr_node_ids, sizeof(u8), GFP_KERNEL); > >> > + if (!new_iw) > >> > + return -ENOMEM; > >> > + > >> > + mutex_lock(&iw_table_lock); > >> > + bw = node_bw_table; > >> > + > >> > + if (!bw) { > >> > + mutex_unlock(&iw_table_lock); > >> > + kfree(new_iw); > >> > + return -ENODEV; > >> > + } > >> > + > >> > + old_iw = rcu_dereference_protected(iw_table, > >> > + lockdep_is_held(&iw_table_lock)); > >> > + > >> > + reduce_interleave_weights(bw, new_iw); > >> > + rcu_assign_pointer(iw_table, new_iw); > >> > + mutex_unlock(&iw_table_lock); > >> > + > >> > + synchronize_rcu(); > >> > + kfree(old_iw); > >> > + > >> > + weighted_interleave_auto = true; > >> > >> Why assign weighted_interleave_auto after synchronize_rcu()? To reduce > >> the race window, it's better to change weighted_interleave_auto and > >> iw_table together? Is it better to put them into a data structure and > >> change them together always? > >> > >> struct weighted_interleave_state { > >> bool weighted_interleave_auto; > >> u8 iw_table[0] > >> }; > > > > I see, I think your explanation makes sense. For the first question, > > I think your point makes sense, so I will move the updating to be > > inside the rcu section. > > > > As for the combined data structure, I think that this makes sense, > > but I have a few thoughts. First, there are some times when we don't > > update both of them, like moving from auto --> manual, and whenever > > we just update iw_table, we don't need to update the weighted_interleave > > auto field. I also have a concern that this might make the code a bit > > harder to read, but that is just my humble opinion. > > I think the overhead is relatively small. With that, we can avoid the > inconsistency between weighted_interleave_auto and iw_table[]. > struct_size() or struct_size_t() family helpers can be used to manage > the flexible array at the end of the struct. That sounds good to me. I don't have any strong opinions about this change, so I am happy to combine them into a struct. I just want to make sure I am understanding your perspective correctly: what is the incosistency between weighted_interleave_auto and iw_table[]? If I move the weighted_interleave_auto = true statement inside the rcu section, will the inconsistency still be there? Just want to make sure so that I am not missing anything important! Thank you again for your great feedback. I hope you have a happy Friday! Joshua > --- > Best Regards, > Huang, Ying Sent using hkml (https://github.com/sjp38/hackermail)