Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp773094rdb; Mon, 29 Jan 2024 19:21:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqFnJ5XTKCz3v3bNBzDzDDoDCbnXF4zf07EGtruJbCz/QoJz4Agj7uYoSvwA6SUFxsFyHI X-Received: by 2002:a05:6a20:5ca:b0:19c:9ba6:4c21 with SMTP id r10-20020a056a2005ca00b0019c9ba64c21mr468495pzr.24.1706584916750; Mon, 29 Jan 2024 19:21:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706584916; cv=pass; d=google.com; s=arc-20160816; b=ni0C4P2IOvjPFGjuTj/wOI8fNMP99JGVY3JcpsXh4TV6B56NZlRbsSK1sKLHfG+v+r ewOBPbsP5bykw/BkN6Q0C+vAbe2GEyok3c6yIKhRGkegKjaH9EOvg/sLFlHMutWLoZKC gFVZkrHila9Ve6RedlQhK5u/6zxM0gyHEJ0dbrLOL8kaW90bCXWWS2nA2ikOi0L8hXtN J8GjUxdFNbM1RxYqQp1CuINgErtRt31uJ76TQqJSz9imV7E4utvg8u1UW6j3icH9ucb/ 5fqmR/EkbaU9vOKAp/RjvkAfzFV+DBJr9n0tsECljHU5Arku8EgqiJ7iDZOMt3YYEZwg cHAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=ZdSYXTJTTOBfbJGGGSkC7XL6WUta3LivOb1NLXPhRKg=; fh=HMaqAr3nd4CI42QK00xbkZ2ptz6u2jp2160PAzRZM4c=; b=WDxSBT+17QxcbVF7OP+YAilfBtJGdGfgvwgEcVRMOFtbzVFOB2DbxGu9BNGJLDuQMz 4ngpphagbUZBCjOEK863JMZqbM0EI4Ka7u5sS8bpIvCsX4mK3h+Vr0AV/FHWsi4MvSvx b8BEMsqvDvuAxeWbov4FjFyLi4ubOR4F+0565D1mPlk/eQnwOK8xeEV84h7FdD9RF0rJ GGqbbY0D8E4e5FxwbWBKKlazjXFOag//8SaltUibuII8h4xaEZ2gmUS4rnoLcxNL+BQu Dd7rsqPEyr7fOV/5rOJIVRwtKwIlq37Qk9j1jSCci+JSbGhendiuA5tZWBKIOtoSWeIn BVrg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iycBlVWE; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-43876-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43876-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id bx30-20020a056a02051e00b005cdba90861asi6901908pgb.159.2024.01.29.19.21.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 19:21:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43876-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iycBlVWE; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-43876-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43876-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3C126B23874 for ; Tue, 30 Jan 2024 03:18:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE5ED37145; Tue, 30 Jan 2024 03:17:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iycBlVWE" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) (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 95AD6374C9; Tue, 30 Jan 2024 03:17:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=134.134.136.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706584660; cv=none; b=d7iO/0Uw33oFJObVRS8YK4HFTnb5FJpaByfOeBnuTGfoRkfAmTuXc5fnPyjRTQPpSUYzL5wS3KsYQUOZHupZaR/FrIkJkta2eYX0uQf1JALKeL0U1eNtpxSjPHvTeDqS6JkBHIgx8UsShvC1T93IEbhy8nJSsDCkOINMYXbQEKM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706584660; c=relaxed/simple; bh=wcpqROo/Nav+p/3mZ66wGUmf7vdiOv5PYmXgj8P2Y88=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=fwtBITNvQuyDZL7aFpl2JkjJ99uQvOqzuZfuULMu+wk0ew1aYkhaITEa/P0cNeO3ACjWf2paL/PdOlouBJB8aY3sGdXx2yIVcLyp8sxdRasaxXc45rensoKb5yHf+SreSBvKTgXgKVx84vTHmichBOXEsnyMta3kKzp9Tag9QsY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=iycBlVWE; arc=none smtp.client-ip=134.134.136.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706584658; x=1738120658; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=wcpqROo/Nav+p/3mZ66wGUmf7vdiOv5PYmXgj8P2Y88=; b=iycBlVWEqvkF9uAcwSqxI+lk50VQS2frOlFTyMeuXMT9a2g4it/ayJhd 3u/lrR8zuB4gutWN4zPVm+S6Ko7/gPmKQTRY0WoYwrc9XWD90k5kZa1cP BeFoKjKehiZ1Ho0RMpYsml+fTc1Aiccqty17GGAp+uBpSevLUrsBokplu Mm6mv+kpFXVRpVV8rD1RgTvpPFfjC/iH06QZiPeMWVRIiz2WT4m+Mi/Bs SUHGGklAf/pIXNQuoAS7XJzxMZ5P3+GEdmk4sn7TdC70h0eREAgUN0i/J KLeL3boZOLEgXBF9vESqEOWZPbNm6DQrU7ZWu797pym8D6K3p7KeqS0BE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10968"; a="406873069" X-IronPort-AV: E=Sophos;i="6.05,707,1701158400"; d="scan'208";a="406873069" 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii 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