From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (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 E6AB1330B04 for ; Fri, 16 Jan 2026 01:26:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768526785; cv=none; b=bBk7LzgWewgTcm4cuLqKwqcuSLSiaPeZUluTAAxrLztpzUNS3aaVBUbeWPj4C5/5vxiwsLX1hgrVolTO4OJc66BaRpHNCBHPXxB1EgtU+q0P1gpRFR/cwnfNsceu3WaurKnAJkGU4FYaMuW5gS29NlGjiPoJexAim+7lEhHXEwY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768526785; c=relaxed/simple; bh=u2HIwWILQrDzDUPYURuaUHt3YWH6QPnw54rGor2HMEs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iEzzmotNShcQAWL6YdrRgvh1bN+aj81H0UEh4QGuBPHlkgzSwABzkJEhDrdvtz3lUWQQlIj0oaX4L/uLfG/N6IXJupIwhFklhr4OI2g3R2aqK9+OTym3BWZY0b9XHEAhuc2zqFCEWQ+KBHd2q8Q8vGfx5TvWj70Q7yAXa6J5twg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=F6SB+8K0; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="F6SB+8K0" Message-ID: <62e637cf-91e6-454d-a943-e5946bdf7784@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1768526772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HuEXkOxJzOQTfqz9UqIXyqfyYfaVffILd2CeD8duhw0=; b=F6SB+8K0qMEmK182u5aL6lA52ZRM+q9D6PW81v7J9Lg3oK8MITOuakZmdJUuLqTK+OekPF 00mnTc/5gGMxQlvucmY2hezUpIGg5MWqsXgihtgpb+32Xigp+kIsd8hKRkheI1/eDio6GX dFDtp/0tpFTtk+WzhY6W6jkJjUagm/A= Date: Fri, 16 Jan 2026 09:25:54 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v1 1/1] mm/khugepaged: move tlb_remove_table_sync_one out from under PTL Content-Language: en-US To: Baolin Wang Cc: ioworker0@gmail.com, lorenzo.stoakes@oracle.com, david@kernel.org, akpm@linux-foundation.org, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, ziy@nvidia.com, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "hughd@google.com" References: <20260115071651.42626-1-lance.yang@linux.dev> <0bc3807e-2c1b-43af-9aab-665ce30d49d4@linux.alibaba.com> <8754b56d-b9a8-4b94-b5bc-982384234527@linux.dev> <26cb8bfa-67a7-43d8-b431-a3307df3e559@linux.alibaba.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Lance Yang In-Reply-To: <26cb8bfa-67a7-43d8-b431-a3307df3e559@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2026/1/16 09:03, Baolin Wang wrote: > > > On 1/15/26 8:28 PM, Lance Yang wrote: >> >> >> On 2026/1/15 18:00, Baolin Wang wrote: >>> Hi Lance, >>> >>> On 1/15/26 3:16 PM, Lance Yang wrote: >>>> From: Lance Yang >>>> >>>> tlb_remove_table_sync_one() sends IPIs to all CPUs and waits for them, >>>> which we really don't want to do while holding PTL. >>> >>> Could you add more comments to explain why this is safe for the PAE >>> case? >> >> Yep, IIUC, it is safe because we've already done pmdp_collapse_flush() >> which ensures the PMD change is visible. >> >> pmdp_get_lockless_sync() (which calls tlb_remove_table_sync_one() on PAE) >> is just to ensure any ongoing lockless pmd readers (e.g., GUP-fast) >> complete >> before we proceed. It sends IPIs to all CPUs and waits for responses - >> a CPU >> can only respond when it's not between local_irq_save() and >> local_irq_restore(). >> >> Moving it out from under PTL doesn't change the synchronization >> semantics, >> since lockless readers don't depend on PTL anyway. > > Cc Hugh who introduced the pmdp_get_lockless_sync(), to double check. > > Sounds reasonable to me, please add these comments into the commit > message. Thanks. Yes, will do. Thanks! > >>> For the non-PAE case, you added a new tlb_remove_table_sync_one(), >>> why we need this (to solve what problem)? Please also add more >>> comments to explain. >> >> Oops, you're right, the original macro was a no-op for non-PAE. >> >> I should just move the macro call out from under PTL, rather than >> replacing it with direct tlb_remove_table_sync_one() calls. > > OK. Cheers, Lance