From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1592322A1F for ; Fri, 20 Mar 2026 19:08:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774033729; cv=none; b=XvoVJJwXbOzngkBbvD/FwNA+ayU7tH/IZg6oC2EhMVXRJX8BiZ9iXnDVCAwbqUHtRIBkEhLDE3TqJFPJMJMvKe3kNiZ5Pv9j3o0VlzKPNJpapn8Px4yRKXzH5+sRHqzg9FNZmunMQEu81Qu7Pp3KEL7yhN1JYAw8Qm+ppPkGD7E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774033729; c=relaxed/simple; bh=m0jZbqQJCMjrXNpCUM1V9JA/iSapyeJjj3jNqnE9qe8=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=d5ES9KYNyjqSr8XHXAadE79dd1Dy4usbsHZXZVKxMtDBFDo0QUMdtV9Zusz8I1dw5xSy6Rh7ctYO5GIOLXZK3CBf6MZdXLLFWerg7hQIsZoa3n5vsDlcbrH5IahLj2wbFLP5XoIJpcMvCtz8tBFVBxb3HA6cD/QTJuAoikFa2/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=FinYUhQY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="FinYUhQY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21DE2C19425; Fri, 20 Mar 2026 19:08:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774033729; bh=m0jZbqQJCMjrXNpCUM1V9JA/iSapyeJjj3jNqnE9qe8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=FinYUhQYLMVCHVDnIOPHoRyqEv/B9UN37GqnpWWUJoD5ovOprusiYYoRVqJjnk1Ut B/+FjL9W2U6G2iQoEd7ZApycx093vLuHJDN9cv8VBAwvyhRcSbCyJMZy/AeXyBokjN ue3SWlXnNiBUhStbD3RvV4nI7vOcs6JID7prDKzA= Date: Fri, 20 Mar 2026 12:08:48 -0700 From: Andrew Morton To: Joonwon Kang Cc: dennis@kernel.org, tj@kernel.org, cl@gentwo.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] percpu: Fix hint invariant breakage Message-Id: <20260320120848.ba7ddc21aaa4edab8c2b5b58@linux-foundation.org> In-Reply-To: <20260320115214.143933-1-joonwonkang@google.com> References: <20260320115214.143933-1-joonwonkang@google.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit 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?