Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755551AbdDLVQd (ORCPT ); Wed, 12 Apr 2017 17:16:33 -0400 Received: from resqmta-ch2-03v.sys.comcast.net ([69.252.207.35]:57478 "EHLO resqmta-ch2-03v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755137AbdDLVQb (ORCPT ); Wed, 12 Apr 2017 17:16:31 -0400 Date: Wed, 12 Apr 2017 16:16:26 -0500 (CDT) From: Christoph Lameter X-X-Sender: cl@east.gentwo.org To: Vlastimil Babka cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Li Zefan , Michal Hocko , Mel Gorman , David Rientjes , Hugh Dickins , Andrea Arcangeli , Anshuman Khandual , "Kirill A. Shutemov" Subject: Re: [RFC 2/6] mm, mempolicy: stop adjusting current->il_next in mpol_rebind_nodemask() In-Reply-To: <97045760-77eb-c892-9bcb-daad10a1d91d@suse.cz> Message-ID: References: <20170411140609.3787-1-vbabka@suse.cz> <20170411140609.3787-3-vbabka@suse.cz> <9665a022-197a-4b02-8813-66aca252f0f9@suse.cz> <97045760-77eb-c892-9bcb-daad10a1d91d@suse.cz> Content-Type: text/plain; charset=US-ASCII X-CMAE-Envelope: MS4wfI0Ud+KnC44Oe3OPkgtYd3IsOAoLFQBs3oP0qhxbOEs7rD95fP/Vh7Vjbo/kXoCEBotlgvsDzOOkbPiYLZfgVgVC+E9dPC2MagWjCivSYvEwQZQoGdIP Nt5poeJRrkRqSTQaPK8Sxj8khqotbJAOZbiR3ZF5BmQg3Z/RWTCs54flnhpZYD3PMLr7fJhzmQiucRuaPh1yJQTUlFNZVgwRJzpHHr3PRDYsHdfn1Y9lGytS URHkMUZ+oz+MDACt+wuYiw+DwFjcIscLi/1XwdSmDOU4PJw70fvXt+MTEzI2igPnXL2ki3HdoDWjKNfJgBxOBuYRDU7TV06MkpUx0DOny4O2DTIEJOwgycCl N8NRnvO0Xg+/X1/eJJnRRPCO1jzvYmX8wBJhCjFuTjxUAAemPLQZ+9Q2zj85G73K7OadV22oatYhgGi7AGRx2pjLkOLp+hVQfb7D2zRUy3///VvcxGhjDYwG N0e2HA9V5DfaT6ZzPZdYhsRYb1872nDCeBr8xW1LF3YbjNxB+41DfJt7Hwo= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1651 Lines: 45 On Wed, 12 Apr 2017, Vlastimil Babka wrote: > >> Well, interleave_nodes() will then potentially return a node outside of > >> the allowed memory policy when its called for the first time after > >> mpol_rebind_.. . But thenn it will find the next node within the > >> nodemask and work correctly for the next invocations. > > > > Hmm, you're right. But that could be easily fixed if il_next became il_prev, so > > we would return the result of next_node_in(il_prev) and also store it as the new > > il_prev, right? I somehow assumed it already worked that way. Yup that makes sense and I thought about that when I saw the problem too. > @@ -863,6 +856,18 @@ static int lookup_node(unsigned long addr) > return err; > } > > +/* Do dynamic interleaving for a process */ > +static unsigned interleave_nodes(struct mempolicy *policy, bool update_prev) Why do you need an additional flag? Would it not be better to always update and switch the update_prev=false case to simply use next_node_in()? > +{ > + unsigned next; > + struct task_struct *me = current; > + > + next = next_node_in(me->il_prev, policy->v.nodes); > + if (next < MAX_NUMNODES && update_prev) > + me->il_prev = next; > + return next; > +} > + > /* Retrieve NUMA policy */ > static long do_get_mempolicy(int *policy, nodemask_t *nmask, > unsigned long addr, unsigned long flags) > @@ -916,7 +921,7 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask, > *policy = err; > } else if (pol == current->mempolicy && > pol->mode == MPOL_INTERLEAVE) { > - *policy = current->il_next; > + *policy = interleave_nodes(current->mempolicy, false); Here