From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 238C6175A76 for ; Fri, 10 Apr 2026 17:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775843394; cv=none; b=kHhabYcbvad3dLmS4OjlPhbeiS3HtdcaMScOzq8yFP3520TxGUzLRjuGTMDQl7IHuRFkqbAK2ZtP+Y+pEeX9AOAda9dHGZG3E2EFxEAb/LTZ3lPh9IbzBMsLWvOyKMQuz6y8f5dghy39Ys2zzMYSBxY5vRJGDROlZKJPe2Feyrw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775843394; c=relaxed/simple; bh=pqlrCjQbCoMls4doY/ixCDr4gs7dpk/I2Hvcvge1n98=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=oepTw23g0KKSyYlz0afGEV/aoDpa1KEsy9Y6ER7EdCZ6RRMHyepwBVeZQizxgUpOlJH6Tvcx7bjUMyOgSzstFFQQx0/F44/uIM1GpSlSieFp7yc0Af733pYDukU9qIbnnyZIN99+ZKx59KdbqpjhKYQ6Jg/84dxi+4dk+pDb9J0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--joonwonkang.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=aQK1eUck; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--joonwonkang.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aQK1eUck" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2b242cbb97aso18421805ad.1 for ; Fri, 10 Apr 2026 10:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775843392; x=1776448192; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=n63njisaqyt6Z3ldieTKgF4Vzk2yvDqsctxyE+mfFKk=; b=aQK1eUckTi7AT39VFGphRoJVSLW3IhhYaQ9YnOsFYrOcpxQ103FcOHQRvAoFKG8VVx mEHm1+iW1qO0Ql2zGvE+7B1UeufR6i04IIevDdMJ386A92zqcV4WYbCf6MnhqBYBuaLT gIFNaP/xwEq6QeAPimijeS5jUOSBomwiCOhl8l3kwTN49qLBsO7tuLJRZn+/X7ukOPqx 3vG8TkZKUVpQ62027mhV6zIsZ++R+julXkHf6ati/kMIAKBr5xR5sMBufapb55pPP+sq ZnoQxLOl85ATLiC68RFK6udGRsE+HA6c8p8FBYvfTUKt4/KaveRp9mnmU75Ks7iAZVmf Eq0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775843392; x=1776448192; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=n63njisaqyt6Z3ldieTKgF4Vzk2yvDqsctxyE+mfFKk=; b=ixOlfJFkKt6ixRECNbXfE28f6i66l9W+/a2TWp/asQMeRJujp0mMzaYLut3BYJk4tc RWQTu8Vqzw824/DthNdq038lAgssWsn1zij4RP2M3cUdq0Gth0oCwbTdhH6BNRHDY9Jx mMc6/u8mzUL2yrHlEjUjWIyw+9UMrhqt4P+rLolxzn1XWoPrFtNjELFY1pOeXaYW2yKw QeEVcqItk5/LaLYxfjdLdzOHG9D1d9SNj+HjArcwyDYUqI3/VUvAUlGx/klYhG/rIpcr n0ITRGxj6dqeUMrkEf/rWftfM3zg8VED41jBJPHIv0cXgEFSmr3K/qgBfkZMnus2WPCZ 5AHg== X-Forwarded-Encrypted: i=1; AJvYcCU5aD4uWpKPoPDZH7NkxcduTj29g3CK3da2ens62J+0zSjVIGxaDGO/fwkKTKDwRQV4r5v5SoX/EtT/GNs=@vger.kernel.org X-Gm-Message-State: AOJu0YwnPylVC7IfxsD0Txi21UXzOoRp56MsAATnSU8V/qO8WHquLSM1 xaKmTjItv5KZDPuGCp7+UYM98aED7DIeof2/fzfIhfswujq453I880iwrqB6pJ8E+hC446L1axU 1Oo4dGMdYomzmrBE54fAbh2sBTQ== X-Received: from pllk22.prod.google.com ([2002:a17:902:7616:b0:2b2:4f11:11b1]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:7886:b0:2b2:5042:dd18 with SMTP id d9443c01a7336-2b2d594152bmr32774695ad.3.1775843392243; Fri, 10 Apr 2026 10:49:52 -0700 (PDT) Date: Fri, 10 Apr 2026 17:49:50 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260410174950.1454063-1-joonwonkang@google.com> Subject: Re: [PATCH v2] percpu: Fix hint invariant breakage From: Joonwon Kang To: visitorckw@gmail.com Cc: akpm@linux-foundation.org, cl@gentwo.org, dennis@kernel.org, dodam@google.com, joonwonkang@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, tj@kernel.org Content-Type: text/plain; charset="UTF-8" > Hi Joonwon, > > On Wed, Apr 08, 2026 at 10:06:42AM +0000, Joonwon Kang wrote: > > The invariant "scan_hint_start > contig_hint_start if and only if > > scan_hint == contig_hint" should be kept for hint management. However, > > it could be broken in some cases: > > > > - if (new contig == contig_hint == scan_hint) && (contig_hint_start < > > scan_hint_start < new contig start) && the new contig is to become a > > new contig_hint due to its better alignment, then scan_hint should > > be invalidated instead of keeping the old value. > > > > - if (new contig == contig_hint > scan_hint) && (new contig start < > > contig_hint_start) && the new contig is not to become a new > > contig_hint, then scan_hint should be not updated to the new contig. > > > > This commit refactors the percpu block update code to make it more > > visible on what to consider, e.g. when the new contig overlaps with the > > old contig_hint or scan_hint, fixes the invariant breakage and also > > optimizes scan_hint further. Some of the optimization cases when no > > overlap occurs are: > > > > - if (new contig > contig_hint > scan_hint) && (scan_hint_start < new > > contig start < contig_hint_start), then keep scan_hint instead of > > invalidating it. > > > > - if (new contig > contig_hint == scan_hint) && (contig_hint_start < > > new contig start < scan_hint_start), then update scan_hint to the > > old contig_hint instead of invalidating it. > > > > - if (new contig == contig_hint > scan_hint) && (new contig start < > > contig_hint_start) && the new contig is to become a new contig_hint > > due to its better alignment, then update scan_hint to the old > > contig_hint instead of invalidating or keeping it. > > > > Signed-off-by: Joonwon Kang > > --- > > v1 -> v2: Consider cases where the new contig overlaps with the existing > > contig_hint or scan_hint. > > > > mm/percpu.c | 124 +++++++++++++++++++++++++++++++++++----------------- > > 1 file changed, 85 insertions(+), 39 deletions(-) > > > > Just a few minor style nits; checkpatch.pl reported the following: > > CHECK: Lines should not end with a '(' > #173: FILE: mm/percpu.c:653: > + overlap_with_contig_hint = pcpu_region_overlap( > > CHECK: Unnecessary parentheses around 'scan_hint_cand_2 > scan_hint_cand_1' > #258: FILE: mm/percpu.c:699: > + if ((scan_hint_cand_2 > scan_hint_cand_1) || > + (scan_hint_cand_2 == scan_hint_cand_1 && > + scan_hint_cand_2_start > scan_hint_cand_1_start)) { > > Since this patch will need a respin anyway, I think it would be better > to address these together in the next version. > > Regards, > Kuan-Wei Hey, thanks for running style checker for me. As it looked fine when I ran it, I guess you may have run it with `--strict` option. I am not sure if the strict option is required. I will keep it as-is since it does not seem very important unless it hurts readability. Please let me know if you think it is. Thanks, Joonwon Kang