From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 732767E0E8 for ; Mon, 25 May 2026 02:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779675496; cv=none; b=VEy3yQu/atiyP4ko7gCYuQWNyo7j0/qm16KLURD/5sjNIXMP9DJYC8vTPE0Wr2nFQ8EELUpfVWurnwT6DEh0GB8NswvOWDw8q13tcyVyKHq1C2DwMdUqowfh0p4FhNFlRA1Plp2vrPZd6W6W/TzJpKGJAMI6j/y2RDuy5pgYmTc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779675496; c=relaxed/simple; bh=zKUBcoG2YdC/TK2wsJYdqj6ThoTfpF2xngijMKqGEz8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lxCYvPADeF//On6N8HmIU8ld+bV5fUPXc94gba8yXgnOQ4p6hcJvfsa8xfzYUOFdHYhmVI0fYzl42iqf/b/NBZzorDz3o9aZfOAQ+Jz5u/6AfFNx6TU6ujtXUDXaXbrdB7ntuQKX1rwEAeeyc8Rr0jS8vNV/lFRPIDQ6/AJymEw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=j4HYhTJ0; arc=none smtp.client-ip=209.85.219.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="j4HYhTJ0" Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-8cc715824a0so26060906d6.3 for ; Sun, 24 May 2026 19:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1779675494; x=1780280294; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=VLBQ3pVE972YUzDp3Xl4nLs2lFPadjyIs40uEfoMObU=; b=j4HYhTJ0uNtZLX4WWaY9/PQex3TTe+w14XTSjiWTUPH0pkRZPShKNo9ZerKbEs58VF vTpnwBZESkjitWuVijgpdbCNGOktEyQBhShxDFJI4eZL6v3Er3c2WyDGHGavzRV5wpe0 PvF6HM0TySJhNz3xcb9m4RcT7yx5eOFRxogl7h7S9a8l1h9CwPtptyPN/7POKKS7b5tG OZpOPjeGGO9klegzwErg1L4L2WOove3O5dT4PiANU7rwUnQBuj1ck/jzd1J4PW3BOR5p Vo5EJ5yLqJXClE4owDv5CfK3GFdST/omMrJZaQMgifGs+5bLYj3CWzkbZI+ya5S3hcxe 5Tcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779675494; x=1780280294; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VLBQ3pVE972YUzDp3Xl4nLs2lFPadjyIs40uEfoMObU=; b=lPk8eoR2rPzlcYl+NCn6umIEvUq6zEL77jRhBnZPWtLkkhLSyVs2c0i47t6G1dg83T jUiEjiZd8iyr/RKRnlZVaYSFd/PTSrvTiyaHhQG3fJzPO9gU2spJWqFRVSHajkHB1nde 8cS9R+9sZNU0s/jsomk8gj1uU2yz6gfNLnmbxcbeR0YrYfffa7GBxo7+iqYiEksltuxy 1lG825p5Q9cEJkamPCjJXe8JFJkbRhxwv4qjFg/xih4whQAjtgpBifxXsWr+omBzQVYw vAM/vhYzmPHCBYxIWDyDYG7Z/+f7urWW6Ssz5HJ+We3U+DCbaKk25ZAkyMv5F5XLzH+R sOhg== X-Forwarded-Encrypted: i=1; AFNElJ8P2ucZmB3KerNcG61oqOdp1z0vEYUhB6rb73MgaaQfuj8mJSF9x/Aabdgg490BLRz8NDpW5xhf8VByLRI=@vger.kernel.org X-Gm-Message-State: AOJu0YyiTYPUzmrDLSSgnJ6alnD2n2TuF2p7Q6pteXhzqKuOhI092dyt F+4T2LYWMkupgKUcF7OXK7rBWPN5ZXH2HlUFl1cjKKmKruZ4QucHZLWT7k/BZSVou6A= X-Gm-Gg: Acq92OFJUKgiCxYr7RQxl25cd6a4V3fE6TdN3sf/jjWNTCjztI6CGF4Ry3HYJptDfBr U28+fjyEUCMh59mG57I+yEnumfT+wbe9mnDwxip61ILJxn57KwSUr8Ul89mZ993O0ZpJplext/z YBkoZQNNIHexffCMpD+tj6RIjLzggmhkzFDgGQCl8jQwjYVeniTvv+I8iDU+JgYlSTu8MdeSVrc Ak/nZqmglDBexLvys0bzFD44uvh9Ibvpv3UUuJKouNVKYGohMEU6fdwU1t/aQJ2HOea/8HQaTrV gKWmLe84ogmymKVr4KbpUYM351eQm4YGT6Vh90P7o1wuzTekiHoo8cec9zyWnw4okrKFSl/dmoC 3dk7NTowFUuEzlSHgfJiyu/pDe3E4XbOVE5mFWVOmRfU1Dfs8xFpcTRVJ/5NNLjfTnwhoKPjvsy qhJEBr2Xrd4pEBq56doSo5tDQ6A+QNXhWWmVGHjCaMakJKdETe4sBGof8TlP3ARMhzzqH1cxnsk w9vR6C8qL1EcqyG4O+mfiE= X-Received: by 2002:a05:6214:3d97:b0:8a4:21d9:bbf2 with SMTP id 6a1803df08f44-8cc7b5c53f5mr195484376d6.33.1779675494374; Sun, 24 May 2026 19:18:14 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-100-36-248-188.washdc.fios.verizon.net. [100.36.248.188]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8cc80ded51esm100028546d6.17.2026.05.24.19.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 19:18:13 -0700 (PDT) Date: Sun, 24 May 2026 22:18:12 -0400 From: Gregory Price To: Oleg Nesterov Cc: Alistair Popple , Andrew Morton , Byungchul Park , David Hildenbrand , Joshua Hahn , Matthew Brost , Rakie Kim , Ying Huang , Zi Yan , Jann Horn , Kees Cook , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/4] mm/mempolicy: kernel_migrate_pages: simplify the usage of put_task_struct() Message-ID: References: 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=us-ascii Content-Disposition: inline In-Reply-To: On Sun, May 24, 2026 at 06:57:59PM +0200, Oleg Nesterov wrote: > kernel_migrate_pages() calls put_task_struct() twice; this complicates the > code. Move put_task_struct() to the unified exit path. This also allows us > to move the "out_put" label up and avoid another goto. > > Signed-off-by: Oleg Nesterov Reviewed-by: Gregory Price > --- > mm/mempolicy.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 4e4421b22b59..4326dff16aa6 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -1922,25 +1922,20 @@ static int kernel_migrate_pages(pid_t pid, unsigned long maxnode, > goto out_put; > > mm = get_task_mm(task); > - put_task_struct(task); > - > if (!mm) { > err = -EINVAL; > - goto out; > + goto out_put; > } > > err = do_migrate_pages(mm, old, new, > capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE); > > mmput(mm); > +out_put: > + put_task_struct(task); > out: > NODEMASK_SCRATCH_FREE(scratch); > - > return err; > - > -out_put: > - put_task_struct(task); > - goto out; > } > > SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode, > -- > 2.52.0 >