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 0CA4037C90E for ; Mon, 23 Mar 2026 12:02:13 +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=1774267335; cv=none; b=lMxX7Rtrn5G6As0o8b7isSQwHy2XawByMr2Ylb7Vetixq+tdkgAmmn8PF1yxbohFJoMwnIKlwAI7hi1Eh/7NbFPPAfMBIaobag5ql+RMQ3CyoPxNNGa98lx65Iys7GfYPVsu+AuK8+aOYljC7aAeYTIewmhMlN2+mCI8mIo1cso= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774267335; c=relaxed/simple; bh=l5vXGbVKPOHwux8NjI8KLbi2QHrbxN+Bhr5fG5dYl8U=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HDh6zGfjJUNpya2y2/9NJVlvk+AN7caRBSCNPcIfeI1qKfUTHUrbDVwWx53iIQ5FIRXzx1EGQjgbYltASV3R7BODJkWO2HPQDODSuvNppoHGuXCJvTnFyn1gewaKYI2O4DvNMV4XF3TT8QiEcYi/i5nAfqexRE90a8exw+co3ic= 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=vxdNvLUf; 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="vxdNvLUf" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2b05370ec01so279918475ad.1 for ; Mon, 23 Mar 2026 05:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774267333; x=1774872133; 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=11OQ308MFdLAcgnywhabzk972DmGk7CFqQqmesqWA8U=; b=vxdNvLUfXmcj9rMt9Z2FOZapr/jM8NT0+zIdcpQtCE8OEDDtMc5EZa9mdwu3+alOvd SIWkPcgUw9z1fJzKXSMzgvXjBvJ+koR9luKvCWnWkKOvYN1420XWA21begAatUoxdx3u yh/ej+UhSeV9UYpHleLmknKWjiOxnuaIWBNg4XRIwpmRdinsJyDqlF7YyIFepg59+BN+ wrR4eYh2g3BDm5cEkRAp2PFb07e/NKVqodkiTcN9rCgu5rJglR2vEJG+kv8vWF0p7N6o 8y+uiyv42bs/CuLwbhEFEnSbe7R8EiyF7BB4Ez8wHfBCuAdiOP3+9C+YT9kp9Rz9wcnv XKPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774267333; x=1774872133; 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=11OQ308MFdLAcgnywhabzk972DmGk7CFqQqmesqWA8U=; b=UKvayT55JGtLceQgo1N9ePWIo5G3hZwzI7vkwEONQ93+cRgWHE9v/isY6Adawerjoa 8gyleB1cApHClE8JIiCdxU6NIEDCKiWwIsbwfrtIeVLLk544JrY9hlcn98guALa2+yUR nDUXhDYu8c2ytaSEYaFcdzNm/BuxQof9em4oj/V+KvwluoXx6jdtenbBj60r4vJKcqS5 viqItDerP6nQRMDdbymaT13xeom7obAkNbho+N6TvCP7uafx7eft0sIU85xSekA9rDRJ 82Me5XqAgO1ePXRpRfK+NlUYS8inFMIhrtf6v1WR+/j7Ix6A3tbUgv9m4k6fpOlCrpfl eM7A== X-Forwarded-Encrypted: i=1; AJvYcCWO9ogHcvphaH0Kg9UkCEgf1OjEp/09cSaoAlKvZOqczcTsceBxo5YroOvknfZOmWjV7jBxab7qn6S4JFI=@vger.kernel.org X-Gm-Message-State: AOJu0YzrCjwdhZL5CGNVn/l0s8gdvwtf52nTOSSnFQ/aRJAKhHRQtYVE BLDiw06j+V5nqQPD6dq36npDMJu/+ZKq+b0ImFreIdJGG9I/yxctwnLfksUA687moxXjEfCMDqM 6Dny4D+ewcBUs/N2P3iJXNf2qDw== X-Received: from plba21.prod.google.com ([2002:a17:903:1015:b0:2ae:4efe:f1e9]) (user=joonwonkang job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:e74b:b0:2b0:5b4e:370c with SMTP id d9443c01a7336-2b082793bb0mr118653695ad.32.1774267333193; Mon, 23 Mar 2026 05:02:13 -0700 (PDT) Date: Mon, 23 Mar 2026 12:02:11 +0000 In-Reply-To: <20260320120848.ba7ddc21aaa4edab8c2b5b58@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260320120848.ba7ddc21aaa4edab8c2b5b58@linux-foundation.org> X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260323120211.3433694-1-joonwonkang@google.com> Subject: Re: [PATCH] percpu: Fix hint invariant breakage From: Joonwon Kang To: akpm@linux-foundation.org Cc: cl@gentwo.org, dennis@kernel.org, joonwonkang@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, tj@kernel.org Content-Type: text/plain; charset="UTF-8" > On Fri, 20 Mar 2026 11:52:14 +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 it. > > > > - if (new contig == contig_hint > scan_hint) && (start < > > contig_hint_start) && the new contig is not to become a new > > contig_hint, then scan_hint should be invalidated instead of being > > updated to the new contig. > > > > This commit fixes this invariant breakage and also optimizes scan_hint > > by keeping it or updating it when acceptable: > > > > - 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. > > > > Thanks. Does the change have any observable runtime effects? > > Was this patch inspired by code inspection? Yes, this change basically comes from manual code review. While there is no benchmark result or others backing up the effects of this change, Dennis may help on that later as he suggested in another review. The main point of this patch should rather be fixing the "theoretical" invariant breakage cases. Thanks.