From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 5F2123346B6 for ; Tue, 6 Jan 2026 14:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767711362; cv=none; b=jpKofdvO31Mip/1XBKnloiqNx0HEIrdTSnvH0qekM6SCsOQlGOPoQkzTTeUh9WN7qShuoh2oZC9zDtbv3Uxwnn8277nKrhW9UnmTYeyF/BUbYMa0Kc5kZQqeF+zhAPpTb8+3JbqHVQVI5XBIjsC9s5lYYUPR7TAva/5Vmq0u9hs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767711362; c=relaxed/simple; bh=rVVLccVp62xBaZt9xAeW213gw+s/Q47hvM6/TG2i2BA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NT+Su3SjWtXZrn2SznK/s/5N2eohF1txO40D6KfXUYznVPu5wuxw5PWb4r3MCpEtMESyTsfZjsJSq5NS6VwBIh2ICpFU7Aunys3KzKSkr7MQSlYOROBoigYT7R8DEPD6Z449I/9CEH04S92luna+Bopd7H0JeXyyT4OdMRXJYKk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=VRTEBNVV; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="VRTEBNVV" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-431048c4068so649657f8f.1 for ; Tue, 06 Jan 2026 06:56:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1767711359; x=1768316159; 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=48vtN06ZLYir8q2EkdgDzMinaXOPY0b17Zy668Z2E7M=; b=VRTEBNVVYJq+aVNiVbQYY337DajCWxtQDgVQDG+XI3Qvpfpr0637oVyCv6dP4LI+WP HP+hw3CWNxAwvjBKWvPHCiVckdUCJoJZJJlW0w1+nBaunwNnMsuYtB62q/SHATzdp4e6 uJaUfCAqUv3l8EZRywHrlnpdDEIeIdzPoeLMDtFeAFsPERAhpMV1E1OrlkTRCJzXXzJc s8IpMWfcBCKU0ZoI58nQdKo2nLlxpZ3h7VTCcszqzA9NwgYAlW5VMO1GlO9UC29ntLzs A6mXDaTMQpLeO3nPTTbZf4RRLh3GJRKleV+QqaZ1T76RjpDtusjLHu0FHQDQN1DVFLJy itFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767711359; x=1768316159; 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=48vtN06ZLYir8q2EkdgDzMinaXOPY0b17Zy668Z2E7M=; b=pIPh6X8aIexIWFFbSJksa186RZDrmBQW4veVVlH3hP8fYm8jfoVUNbt4gO2PsMa8DM KIZr889JYMkElalc8d4RUbqIx80lLPUpjK/vb8bjpqgBCi+S5QDmRWRcJ5TBdvAfwUhB RpfFXK+c+OrF4Tte4u9rDXIe4cSg7TuRLOOZu4Yd6szERK3HTunHg88suY7zoH8U7l0m wcO8E9QVc+QoNWwK1ETwhcqjdmTC+vNTEsvIAqGDteZUG/P/TfbH3JC0Pu2O1f+hKlfX Hbnos28drIllFEKkznfbRU0Houo/xSJAZzR8JioguAd/KLXVtzqut1DNsG+9PnsK+M4U /LHw== X-Forwarded-Encrypted: i=1; AJvYcCVmjs34snddcbotrXOsDyHbNWN3BxrSSbrCDeHUHzuReYF5RQou9udM2FJpGEYypCtI4AZo/9S9utXqVO8=@vger.kernel.org X-Gm-Message-State: AOJu0YyxILDvfyoM5mdh2XaQaElf2JaSUtIj1mxyWxXQN3WVH6jP0pBR rzG4WnA1okSNfNz4fCmeMnKmj6ZW+4PGUipHzSHZqVXUu7xT5uUJw5f6ugaTFZQmi5g= X-Gm-Gg: AY/fxX7FKLa3+8XWAsqFNwdpaAzWhUmqAplBdG+JbOpkagjf5/w2HMHbvqzCoe2iDWh g+AtukdE+z8klAG6z8hvf8X9YdPnBsY7vDsLHUr1MbJr+P0N883+TTOkpGyk5liXR+Vtrks2rPg Zo3AAd9eMGDGy6tBmCk5IJUVhG7Eyg4XT3ulPthV5ef+YCsnIjM0HxgGE8Lzibhp3vPH3DvYNDZ D8fYmpu/92f/Extr+e1fDFMHZfZL3WR9ak5EA9vL55dX5Ll5re8ffbENDCPZTTae3wjLCLPfP9I u4MY+oumbrHYTrliYK45KYuPCOEjP/+EmMJ16drPZ0/3Fy2JE/rhp3pc92UQmZYxMabSidGZvLz IPqabog0Rh3SSyvgUydmfbzgtIYq8hEyUxcin7ZXxQWuiyS2XX1bnzp+r/FGLJ96sKBwju7vihd PG+kJfd1m6lBGJH4MgZN9RN5eB X-Google-Smtp-Source: AGHT+IHhhGmMFo4brBzmqdaikap8XFUd2NZ2e3OzIHLOdjpg5aOZMdc5gOTVtmUPqWIaAEFBQ6dtxw== X-Received: by 2002:a05:6000:1886:b0:432:c03e:a77e with SMTP id ffacd0b85a97d-432c03ea994mr1875519f8f.16.1767711358634; Tue, 06 Jan 2026 06:55:58 -0800 (PST) Received: from localhost (109-81-90-116.rct.o2.cz. [109.81.90.116]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd5df8besm4578637f8f.26.2026.01.06.06.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 06:55:58 -0800 (PST) Date: Tue, 6 Jan 2026 15:55:56 +0100 From: Michal Hocko To: Hua Su Cc: akpm@linux-foundation.org, vbabka@suse.cz, surenb@google.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hua Su Subject: Re: [PATCH] mm: fix execution order in alloc_contig_range_noprof Message-ID: References: <20260105133250.763076-1-suhua.tanke@gmail.com> 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: <20260105133250.763076-1-suhua.tanke@gmail.com> On Mon 05-01-26 21:32:50, Hua Su wrote: > Fix the execution order issue in alloc_contig_range_noprof where > drain_all_pages was called after start_isolate_page_range, which > may be lead to race conditions. > > Based on community patches commit ec6e8c7e0314 ("mm, page_alloc: > disable pcplists during memory offline") and commit d479960e44f27 > ("mm: disable LRU pagevec during the migration temporarily"), we > disable pcplists and LRU cache before page isolation to ensure no > pages are left in per-cpu lists during isolation. What exactly is the problem you are trying to fix here? Is this based on code review or are you hitting any real problem. I find the changelog rather hard to grasp. > Signed-off-by: Hua Su > Signed-off-by: Hua Su > --- > mm/page_alloc.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 6a47443c48ff..d08f929ca64c 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -6815,8 +6815,6 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, > .reason = MR_CONTIG_RANGE, > }; > > - lru_cache_disable(); > - > while (pfn < end || !list_empty(&cc->migratepages)) { > if (fatal_signal_pending(current)) { > ret = -EINTR; > @@ -6850,7 +6848,6 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, > break; > } > > - lru_cache_enable(); > if (ret < 0) { > if (!(cc->gfp_mask & __GFP_NOWARN) && ret == -EBUSY) > alloc_contig_dump_pages(&cc->migratepages); > @@ -6973,6 +6970,9 @@ int alloc_contig_range_noprof(unsigned long start, unsigned long end, > if (__alloc_contig_verify_gfp_mask(gfp_mask, (gfp_t *)&cc.gfp_mask)) > return -EINVAL; > > + zone_pcp_disable(cc.zone); > + lru_cache_disable(); > + > /* > * What we do here is we mark all pageblocks in range as > * MIGRATE_ISOLATE. Because pageblock and max order pages may > @@ -6998,8 +6998,6 @@ int alloc_contig_range_noprof(unsigned long start, unsigned long end, > if (ret) > goto done; > > - drain_all_pages(cc.zone); > - > /* > * In case of -EBUSY, we'd like to know which page causes problem. > * So, just fall through. test_pages_isolated() has a tracepoint > @@ -7076,6 +7074,8 @@ int alloc_contig_range_noprof(unsigned long start, unsigned long end, > start, end, outer_start, outer_end); > } > done: > + lru_cache_enable(); > + zone_pcp_enable(cc.zone); > undo_isolate_page_range(start, end); > return ret; > } > -- > 2.34.1 -- Michal Hocko SUSE Labs