Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3872640rdh; Tue, 28 Nov 2023 06:12:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEepgtx1s8E4xZNzyF5FNaOE7g6EnvxaKfkPTAQj8oKVyu3HNa7fgksDXFl8mr1fNm9EPpQ X-Received: by 2002:a05:6e02:6cc:b0:35c:88b3:98c2 with SMTP id p12-20020a056e0206cc00b0035c88b398c2mr12366295ils.19.1701180761810; Tue, 28 Nov 2023 06:12:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701180761; cv=none; d=google.com; s=arc-20160816; b=iuqvlEsa8sOo8ln6lkK+cCzk1j4cxXOi5REmzGZparYMLsFywlQj6rtJZZWyHmJrik CXDYTYAMM4AXSnsHwg35njgolJwURgpz+P8GRRmxRqe4GOzJpam2gPn4Flui97Meglq2 GMwskg5qRUsvo7cV4HDuouSg6Po6/26T0Nwi9WsLAU210jOKC99Ff6Vg12HxM7cNEKzm Xin4yc183Zp0mW5lLyTQGO+cs/Ps2EvfNaTka0nirhtsu1utBPgduJojoeV1MSClQzDD HdQlGjfmTYzQjBtvLqEqc03O0y44gFbjgUAI0C5W5k9JJBDhnXI3i2zTu+RotMt1v+7G NwIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bZslgzkC5KxsP7jHMJfyQVKff23207T2myOVc/HMRlA=; fh=uK2UhJyeo1vcZbutR8i6ah7jOpqTyh/OSJNpaZi8zro=; b=fa3ikBsAyBqtpByy2Je1OBWK3SQFRxDNgsoWpgZ0RSotMvbihRwsI2Bi01NNYizjav Qv7V3o/ko8zNijZmMwNrTP3KI6P5E86N/CNmdT9Zum/f59d6IU13NhAHE243g42N9bPp 3Dx05AUiHwbgdzj5ttrugZAimGrm1aMnGbgis902pti6i9tIYIU7Fq5DXcrKmwGKO6ET C7rFV6NInuXJnFoMKoOgx2xVclUqhlth7jh+EQZSKUMuQ5zOqrZIeHAb9F5V5HlMVNC6 4I0+TJpfU8wA1QUacHcuEdYVQVM8KC4WlVcdwzu2wFcewnPpjqVxdJsGqFuSGJBf/nxs LHxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=gOLpy9oo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id j9-20020a63e749000000b005bda77217eesi12263468pgk.209.2023.11.28.06.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 06:12:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=gOLpy9oo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 49D21808204F; Tue, 28 Nov 2023 06:12:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345673AbjK1OMW (ORCPT + 99 others); Tue, 28 Nov 2023 09:12:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346372AbjK1OMH (ORCPT ); Tue, 28 Nov 2023 09:12:07 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A997119B2; Tue, 28 Nov 2023 06:11:12 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1C93B2199E; Tue, 28 Nov 2023 14:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1701180671; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bZslgzkC5KxsP7jHMJfyQVKff23207T2myOVc/HMRlA=; b=gOLpy9ooR5alEUjxfM+2syKJDlcrb3FB5iXQd7qKs9JYJFcQmpltz/bEmpMZcZ6R3AK0uo Ecf64Donp/eqfIQGF64lFT4dMv/1bhH5kg/T9LU7xZCHWFRUsuvgVtO1yucw6i58Z2mYeq YMg7dG+ez05xRcpfxL8in70wUt8APcI= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E8B481343E; Tue, 28 Nov 2023 14:11:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id /3/NNf70ZWVIOAAAD6G6ig (envelope-from ); Tue, 28 Nov 2023 14:11:10 +0000 Date: Tue, 28 Nov 2023 15:11:06 +0100 From: Michal Hocko To: Gregory Price Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, arnd@arndb.de, tglx@linutronix.de, luto@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, tj@kernel.org, ying.huang@intel.com, Gregory Price Subject: Re: [RFC PATCH 06/11] mm/mempolicy: modify do_mbind to operate on task argument instead of current Message-ID: References: <20231122211200.31620-1-gregory.price@memverge.com> <20231122211200.31620-7-gregory.price@memverge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231122211200.31620-7-gregory.price@memverge.com> Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spamd-Result: default: False [0.70 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_TWELVE(0.00)[19]; FUZZY_BLOCKED(0.00)[rspamd.com]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Score: 0.70 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 28 Nov 2023 06:12:37 -0800 (PST) On Wed 22-11-23 16:11:55, Gregory Price wrote: [...] > + * Like get_vma_policy and get_task_policy, must hold alloc/task_lock > + * while calling this. > + */ > +static struct mempolicy *get_task_vma_policy(struct task_struct *task, > + struct vm_area_struct *vma, > + unsigned long addr, int order, > + pgoff_t *ilx) [...] You should add lockdep annotation for alloc_lock/task_lock here for clarity and also... > @@ -1844,16 +1899,7 @@ struct mempolicy *__get_vma_policy(struct vm_area_struct *vma, > struct mempolicy *get_vma_policy(struct vm_area_struct *vma, > unsigned long addr, int order, pgoff_t *ilx) > { > - struct mempolicy *pol; > - > - pol = __get_vma_policy(vma, addr, ilx); > - if (!pol) > - pol = get_task_policy(current); > - if (pol->mode == MPOL_INTERLEAVE) { > - *ilx += vma->vm_pgoff >> order; > - *ilx += (addr - vma->vm_start) >> (PAGE_SHIFT + order); > - } > - return pol; > + return get_task_vma_policy(current, vma, addr, order, ilx); I do not think that all get_vma_policy take task_lock (just random check dequeue_hugetlb_folio_vma->huge_node->get_vma_policy AFAICS) Also I do not see policy_nodemask to be handled anywhere. That one is used along with get_vma_policy (sometimes hidden like in alloc_pages_mpol). It has a dependency on cpuset_nodemask_valid_mems_allowed. That means that e.g. mbind on a remote task would be constrained by current task cpuset when allocating migration targets for the target task. I am wondering how many other dependencies like that are lurking there. -- Michal Hocko SUSE Labs