From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) (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 B57C8358D2A for ; Tue, 16 Dec 2025 12:39:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765888767; cv=none; b=HVaC3AdKCcGVW1f2Klol4DMq2zM0nPl4cHDKMNM1HFuewHc2xWE35AmtiHfQgGYE3q+yusM+4/COMYNG39hwMVzQyoZvWqlhTHOfaxHrFBVCMPg8c7jyO2b4Jc4xx3lv6RVcZ9Fn0s0IrOffNRYgUt6L40Y8o6w+/glw2odi6QQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765888767; c=relaxed/simple; bh=ODOFXdKh7a/2yyeolj4dfSpZo/cGD6EWg9Uz8WCXsU8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ud7FvoEkiz59OuYF5h4yylRuXbJRKQWe9JNjBbX9GqaWkxv1TT7CUsLa7mGmAbOsydC3fwFdVczUjyGQ8u6BlArTFgft5/1WO8+GxM+2bUr/SnNxgQjFW1oic9gHL9OV7qgKzPhfGDo7TVOtNYEsA3+nAMfGXo9ftn3ffBCbb7A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2qiMFQQS; arc=none smtp.client-ip=209.85.208.74 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--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2qiMFQQS" Received: by mail-ed1-f74.google.com with SMTP id 4fb4d7f45d1cf-6450e804cd9so3823951a12.3 for ; Tue, 16 Dec 2025 04:39:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765888764; x=1766493564; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=Zl5vYkOfCeh8vzJ1i3gRdGX7RBaO+Y5siaEC/TfzJu8=; b=2qiMFQQSK1sYqI1EleMXBTcbFsv0cH87wr/PM6JBNiylktXHZiRhfivgox+dN9M1bJ ZDYpO9LZJVStLXOWQ3nz69Hc6SiZc5hh3eH0amEMEEgLHcyPgqY0YB65cTycydBWWLJZ Bf79/wLC2U8I3l4n8p9ZyzSfgfmLy6qKX9uyJCg6mRtObL5xni7RPL55+NsrElmu/jAP 9trWIEMFqoIF4ZI2YJ3WKJpfmMuM3M+eI5+VULcjZaR5QTN2rpkxg4y+7SmlZB/OUmA1 9m36dvwcIQoihRk0rOvhYiBoGvy14j7+mqjGaCwHcunl7K03g6AQkZnNbqPS6U4DrXFQ 7NXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765888764; x=1766493564; h=content-transfer-encoding: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=Zl5vYkOfCeh8vzJ1i3gRdGX7RBaO+Y5siaEC/TfzJu8=; b=W/xGe2DjLoQAqqucwG/E4fWe1Ax/H+/CZUoLAnFoNFImq+SlRw33pxJNASU67f983U 7CjWMqPhdY2S8Cghk/rM8HnSgS3tAlmI+shiWSi+8VDxJ0N9QlLYoGx4LU4+Df5DPQ5j DL9T1J+OQToZp7oB96j4wF15meG+HZV9G0nfBGMOjr+ID+HPIL6wO1iaBnAS0OlH++Tw uKQWS+v1MzmLQI/XGPaNdooMXizuc6UXmbv8mRsMY1Pe2nsc6K6jnV0fju+aqcToDZZa Ev72VXalnKHJ1A/jcduUPHkO49hVonkjAflMvOR5fstBHaf95LnD9TvCpJq3ZjI4wimf SWVQ== X-Forwarded-Encrypted: i=1; AJvYcCX05X5WeCOQC0PjOc5BUwiuPFbw9jeS1mM8LUnaYXwzv5MI7r7JlUuX4OYRNFmE4ULZeyCzWtARYvNCQzk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx36JH8eGfXXxJLH7Nyr2ACs3RyB3YX+gO115BO3aoyfjdpQG/A xQ5vCzBnQa9AzqFNRPHClMSS2EGzKcNvx/v6wSdOhN8AOX2VEyL4DT6+xdBw9E60KBD0h43Do9r FgVchBH4gWYygqA== X-Google-Smtp-Source: AGHT+IHodb6E0igt70QWnGwF16M0BauoX0vq/LCQAwB66mdazNxScaNnSE8J8M2KteYx3re6oS8FbB6Lsn9MBw== X-Received: from edsk11.prod.google.com ([2002:aa7:d8cb:0:b0:643:12a9:41be]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:50c8:b0:64b:3a87:44ff with SMTP id 4fb4d7f45d1cf-64b3a874559mr607042a12.34.1765888763584; Tue, 16 Dec 2025 04:39:23 -0800 (PST) Date: Tue, 16 Dec 2025 12:39:22 +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: <20251212161832.2067134-3-yeoreum.yun@arm.com> X-Mailer: aerc 0.21.0 Message-ID: Subject: Re: [PATCH 2/2] arm64: mmu: use pagetable_alloc_nolock() while stop_machine() From: Brendan Jackman To: Yeoreum Yun , Brendan Jackman Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue Dec 16, 2025 at 12:01 PM UTC, Yeoreum Yun wrote: >> On Tue Dec 16, 2025 at 11:03 AM UTC, Yeoreum Yun wrote: >> > Hi Brendan, >> > >> >> On Mon Dec 15, 2025 at 10:06 AM UTC, Yeoreum Yun wrote: >> >> [snip] >> >> >> Overall I am feeling a bit uncomfortable about this use of _nolock= , but >> >> >> I am also feeling pretty ignorant about PREEMPT_RT and also about = this >> >> >> arm64 code, so I am hesitant to suggest alternatives, I hope someo= ne >> >> >> else can offer some input here... >> >> > >> >> > I understand. However, as I mentioned earlier, >> >> > my main intention was to hear opinions specifically about memory co= ntention. >> >> > >> >> > That said, if there is no memory contention, >> >> > I don=E2=80=99t think using the _nolock API is necessarily a bad ap= proach. >> >> >> >> >> >> > In fact, I believe a bigger issue is that, under PREEMPT_RT, >> >> > code that uses the regular memory allocation APIs may give users th= e false impression >> >> > that those APIs are =E2=80=9Csafe to use,=E2=80=9D even though they= are not. >> >> >> >> Yeah, I share this concern. I would bet I have written code that's >> >> broken under PREEMPT_RT (luckily only in Google's kernel fork). The >> >> comment for GFP_ATOMIC says: >> >> >> >> * %GFP_ATOMIC users can not sleep and need the allocation to succeed= . A lower >> >> * watermark is applied to allow access to "atomic reserves". >> >> * The current implementation doesn't support NMI and few other stric= t >> >> * non-preemptive contexts (e.g. raw_spin_lock). The same applies to = %GFP_NOWAIT. >> >> >> >> It kinda sounds like it's supposed to be OK to use GFP_ATOMIC in a >> >> normal preempt_disable() context. So do you know exactly why it's >> >> invalid to use it in this stop_machine() context here? Maybe we need = to >> >> update this comment. >> > >> > In non-PREEMPT_RT configurations, this is fine to use. >> > However, in PREEMPT_RT, it should not be used because >> > spin_lock becomes a sleepable lock backed by an rt-mutex. >> > >> > From Documentation/locking/locktypes.rst: >> > >> > The fact that PREEMPT_RT changes the lock category of spinlock_t and >> > rwlock_t from spinning to sleeping. >> > >> > As you know, all locks related to memory allocation >> > (e.g., zone_lock, PCP locks, etc.) use spin_lock, >> > which becomes sleepable under PREEMPT_RT. >> > >> > The callback of stop_machine() is executed in a preemption-disabled co= ntext >> > (see cpu_stopper_thread()). In this context, if it fails to acquire a = spinlock >> > during memory allocation, >> > the task would be able to go to sleep while preemption is disabled, >> > which is an obviously problematic situation. >> >> But this is what I mean, doesn't this sound like the GFP_ATOMIC comment >> I quoted is wrong (or at least, it implies things which are wrong)? The >> comment refers specifically to raw_spin_lock() and "strict >> non-preemptive contexts". Which sounds like it is being written with >> PREEMPT_RT in mind. But that doesn't really match what you've said. > > No. I think the comment of GFP_ATOMIC is right. > It definitely said: > The current implementation *doesn't support* NMI and few other strict > *non-preemptive contexts (e.g. raw_spin_lock)*. But this phrasing sounds like there are other non-preemptive contexts that it _does_ support. I would definitely read this as implying that plain old preempt_disable() is OK. I don't understand what those "few other strict contexts" are, nor why the stop_machine() context is included in them.