From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (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 B32087E0E8 for ; Mon, 25 May 2026 02:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779675648; cv=none; b=jjD+6xSqDg1r03aX6odlQTr9YZrRU9YZjF+6dprij7GimIFohNh6xeQ6k0nDkJNmXIAS5ndqWFCkNJjgZP9jpzBH+9mOADFP3dF4i+YkoGeHLvP6lyKaYeOqsH2XuMj39Wix37JrNUpxfYEApZZ6uZp4rnxNwnvOn8NvfkDT4JU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779675648; c=relaxed/simple; bh=D/ws0KJVGeYyNSwvqANhMg7cpakkOYZumirlGT94rzU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=U50d2ObBQAlZx9mf/F6Uc2nV1ZndifwrcZswKSFEZZWJFXyBzpiu3ymdNGKcBIH/3ikbhvAGn9s1eCZPkJM4nNc6GgTZB+kzxUytWHy3hrHfoOE8hh5+rM+0zbFP9O1hpGU1bImFiBvT63z81lU9/hW2RRqAt/y/StSIPkCJsAk= 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=vQwrBZTn; arc=none smtp.client-ip=209.85.160.178 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="vQwrBZTn" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-5165195c8b0so101979011cf.0 for ; Sun, 24 May 2026 19:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1779675645; x=1780280445; 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=8EESnugD7SmRVXa8thBSsJKhJxM/G/3ZcLrzcvVSCzY=; b=vQwrBZTnbh/uSPa9rVTZjomxWrA8eD9brnw8rcFJfkj+dj75WNbV5B6/L+7CA2hZ+x KzIV13NXck/lQyeYxMSo9t+Q9Zl6WT2JAOt3RZS5XcdDGv+yhuTctL6pOpyBGq/zM+Ki YoU4LYp09WFgwinD1/kqB3CXyFT3UyPWt6nCsOmA4b3jzo5Bs/aR2kdKiYe1859ft2TA Zgwp3fLMNPdInNAiiOYGAhKAitha1WN7YD46uNSmUPcBvqaF3J2Veq+jEMZu+TSkUZZj FK4h6oIU2BjhIRR3i+uEFP9tYaCSErp9wUytTaG14n7tH021Pf7ubMvjZTKuhMVxTCWw 8eLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779675645; x=1780280445; 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=8EESnugD7SmRVXa8thBSsJKhJxM/G/3ZcLrzcvVSCzY=; b=rNzBsRzNjcLdik9RC/e+bt94jRDiYQKApHLf484zrsRt5S1GMp52eDlBZJhZCbQQsi d7ln9x0RjDSmuGBkDAxPFNHt4mA47Wx84rfbcFPaAUx8CmNaSND5WkZ6/xMxfnbu4Q9e ko0lvG65Q5xb7U8hdrqzIYbLuG7IZgFgb6z7/lLpWXwnnIapf281ln9Jrg4lB3pfj3hy cbaajNtYw3nH1FCGtS+sqrseLl1QYGMBgrHhrMTXiqmd7Jnyw+mEknzKfGSwnOG+2MOp OXHc/GtddJP62Ta/msJ5Edvwdy7bMVT4jsh+luXGjODW+sHHfpoasdFb2jltICLZLg6P wvqg== X-Forwarded-Encrypted: i=1; AFNElJ+01hwab60O7zDfrnbASbox6ouHcy7WIzHK1/kfEy578XwcR8vrdmUl9hWVT5mzDKCaRSX17CEKH0Rjj6Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzRUBJD0nzRH0r4KtjCqZG5Mx+eHSmzTPS73ZmGTt2IX9TUkA4s z2fqtz+ixjW7GnsAoZ/vR1StCQz9QWvjRdRUrf+2OYFupWYkSfmz32HTIqOpXH2UDps= X-Gm-Gg: Acq92OFsRPu8Lhg1M5FhwQvzyllP6JyCDFsCLY8BB8s2VZwKiTPw1khzfnf4nXJWjYJ 8nX8WwFeOvJ38IxuvpDx2u/KSSW8z8ZT7ig6jwYr3c5rhu7GUZ1PQQncfqXNHoVc3nDhjgrJQk6 nmGKAVokOBoL9AEo87pgY7KX6QG7o74Msp4C0RitPrFriP9UkGrhbvN/pJ59kNE4iqRnbBM/kFV H7WKdeFRUUb4ZUKKiUocS2mvQWgjQ2O/2SbwUxSTAGWwT312HUphN8akUZN4un4fUpl27gRFZ+/ NOMeD9indfVJJ4UVaS2leW9XrYMVd9y4wpNQ3BKJ2h04KwvsZBRRE5zNYPIP1R+iiV7862U0N3n 2KFDsoy1dArriF+yXnKumyjaJovYOhg/TlexvmXB1QjUh7dTwAKuWeq6xqMlnO+Ds1rgFPcrNom kH/vbbPxWC1/IMCkEmnAWrvC1QaAp8MSmgU/X05qJDiaLo+UEurC24Lr5UZlb6c10YXquOxS+lx vzoQCLKXQtT X-Received: by 2002:a05:622a:5c08:b0:516:e833:64f2 with SMTP id d75a77b69052e-516e83367b9mr99483851cf.12.1779675645547; Sun, 24 May 2026 19:20:45 -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 d75a77b69052e-516d8c91f26sm80087331cf.18.2026.05.24.19.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 19:20:45 -0700 (PDT) Date: Sun, 24 May 2026 22:20:43 -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 > --- > 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); > - Hm, I was a little trigger-happy on that review, I just realized that this increases the scope in which there is a task reference held (i.e. we're now holding a reference across do_migrate_pages()) I don't *think* that's an issue, but it might we worth looking at the changelog to see if this was done intentionally. > 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 >