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 3B9B3C47DA9 for ; Tue, 30 Jan 2024 03:17:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3E4B6B00A1; Mon, 29 Jan 2024 22:17:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC5E66B00A2; Mon, 29 Jan 2024 22:17:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A40466B00A5; Mon, 29 Jan 2024 22:17:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 909196B00A1 for ; Mon, 29 Jan 2024 22:17:42 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5DFAFC015A for ; Tue, 30 Jan 2024 03:17:42 +0000 (UTC) X-FDA: 81734517564.30.271FD31 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by imf18.hostedemail.com (Postfix) with ESMTP id BCB501C0014 for ; Tue, 30 Jan 2024 03:17:39 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=HjmKlhXP; spf=pass (imf18.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706584660; 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=ZdSYXTJTTOBfbJGGGSkC7XL6WUta3LivOb1NLXPhRKg=; b=hjbkUdviu0qrHJ7FG4+dcTsEwpUJHdzNOiNmEyrGkrauXItFsI3FAYvJdBVKpUwrKMCoSo 3V9uBvdC/lSbK4J3MLtUkhnXAtjvlTgB+enivrjmzyi6AWRu6m6GBgedoue51uoteXHexX VzI1vc0pJZZpq1imBtmbQ7CjexsUnbM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706584660; a=rsa-sha256; cv=none; b=R77tHQXy/xiBQmfYayVJ5ifjF2N9BU470mNWVhXnvLxntplmpDoDVQXqms2VL69yd0Q5A9 v3FB2ukUODM9FAU+mRVnQwkuQyL3v+J03biWwddK34Vijf/6I71+RVg+HdXhJxIIuvPUaz dFUmVTLk7OF0fZsyy2flGTS2N9hW7Ak= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=HjmKlhXP; spf=pass (imf18.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706584659; x=1738120659; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=wcpqROo/Nav+p/3mZ66wGUmf7vdiOv5PYmXgj8P2Y88=; b=HjmKlhXPj8jd5VKuC1uCOffzdUvQrjBH3lZCCAoDA/sA94LL87vO9Mz6 gJw7pKa+qqIgPax18KI/xZdYGz/x8y20E4To606udBjQap+iozMBKZkBb jV0LBoaS7si/H/bi5mv7r/EDlHaJtH/d6h/ogWqw3zJ8CcVWCLRU0gdcE 5KFqmcgViICgc3OuUqBktngM7NyZwhWIVYmj5KrP8WA0zBDrdYEOWX0Bv P40e1vTs5b+7ilq0aximwWVNdneo4/sU3Jg8Ov50RlzWqADrnNZEhbI+4 wPJA5yMKaGRY8mL5R5I+bcCjnMMbZQq1oEMejtR/3IZHRJDqL2+Zj4r0u g==; X-IronPort-AV: E=McAfee;i="6600,9927,10968"; a="406873064" X-IronPort-AV: E=Sophos;i="6.05,707,1701158400"; d="scan'208";a="406873064" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2024 19:17:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,707,1701158400"; d="scan'208";a="3674612" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2024 19:17:32 -0800 From: "Huang, Ying" To: Gregory Price Cc: Gregory Price , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v3 4/4] mm/mempolicy: change cur_il_weight to atomic and carry the node with it In-Reply-To: (Gregory Price's message of "Mon, 29 Jan 2024 13:11:32 -0500") References: <20240125184345.47074-1-gregory.price@memverge.com> <20240125184345.47074-5-gregory.price@memverge.com> <87sf2klez8.fsf@yhuang6-desk2.ccr.corp.intel.com> <877cjsk0yd.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Tue, 30 Jan 2024 11:15:35 +0800 Message-ID: <875xzbika0.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Queue-Id: BCB501C0014 X-Rspam-User: X-Stat-Signature: dcabtn99tr6o55gsniema9qc4ahrjzqx X-Rspamd-Server: rspam03 X-HE-Tag: 1706584659-466844 X-HE-Meta: U2FsdGVkX1/V45ATDAV6Fe8NcJMFRs99CO9rmZPRqo7H21cvjbZ+9ZOyhq2KCMUlZrU0ZswgGUHYuC07+Wp6EIRsKWGqYv6AL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AOdEOvqTz/rIPH3XNzV/Acj9Dd/BAzmqRGSBuT4cEOAw+OC7F7gcbH0I++Z1y2tXvDLY5ZbGLLNnjELeb2CzqUAIw3OPEqwI4isKsHjJdXSlPF7wTEdmw02QsfNBJ9+/aQW1qd4= 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: Gregory Price writes: > On Mon, Jan 29, 2024 at 10:48:47AM -0500, Gregory Price wrote: >> On Mon, Jan 29, 2024 at 04:17:46PM +0800, Huang, Ying wrote: >> > Gregory Price writes: >> > >> > But, in contrast, it's bad to put task-local "current weight" in >> > mempolicy. So, I think that it's better to move cur_il_weight to >> > task_struct. And maybe combine it with current->il_prev. >> > >> Style question: is it preferable add an anonymous union into task_struct: >> >> union { >> short il_prev; >> atomic_t wil_node_weight; >> }; >> >> Or should I break out that union explicitly in mempolicy.h? >> > > Having attempted this, it looks like including mempolicy.h into sched.h > is a non-starter. There are build issues likely associated from the > nested include of uapi/linux/mempolicy.h > > So I went ahead and did the following. Style-wise If it's better to just > integrate this as an anonymous union in task_struct, let me know, but it > seemed better to add some documentation here. > > I also added static get/set functions to mempolicy.c to touch these > values accordingly. > > As suggested, I changed things to allow 0-weight in il_prev.node_weight > adjusted the logic accordingly. Will be testing this for a day or so > before sending out new patches. > Thanks about this again. It seems that we don't need to touch task->il_prev and task->il_weight during rebinding for weighted interleave too. For weighted interleaving, il_prev is the node used for previous allocation, il_weight is the weight after previous allocation. So weighted_interleave_nodes() could be as follows, unsigned int weighted_interleave_nodes(struct mempolicy *policy) { unsigned int nid; struct task_struct *me = current; nid = me->il_prev; if (!me->il_weight || !node_isset(nid, policy->nodes)) { nid = next_node_in(...); me->il_prev = nid; me->il_weight = weights[nid]; } me->il_weight--; return nid; } If this works, we can just add il_weight into task_struct. -- Best Regards, Huang, Ying