From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) (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 695B33F4825 for ; Mon, 20 Jul 2026 11:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784545975; cv=none; b=tZzvDcmNQ5qm70lAfaq+yU5Rftm1oVBEd6Tl3NgQpwC6tayPnBODmv69IYVgAEwDspDSYukGkol5xCfyTLR/bi8J+wl1cbd2yCrFRvQyCmOt23Kl33gimLMU6eifeMfVIfP1WiLPzToVIlVzCJ8kyO72wQhJ9OFEMjgEcEooygs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784545975; c=relaxed/simple; bh=YC85sL0C5sPv4KY9VIP7OhqoYI+9xbnHEhRKv31+2gk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OTSl0kVKdlzmam8XE6P/xTLLAZZnULcRZSmWHwrzkCEqUKnGcBRnsco0b5lYMj6kyS63RXDIhInooClANbWpLJaWbpJ8rNGIPCU9vQdwcBKRpal6gwC3Aa9iTFOFUWrVXZw8LzzuTm/q049ucgpjmqfk9m78LkirAyP5w1FV8kw= 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=ZpAtUeRq; arc=none smtp.client-ip=95.215.58.177 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="ZpAtUeRq" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1784545971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MDxvOrx4DVj0VV+Y/wV9iOjtsl71lHDlM1UPvEJ30HQ=; b=ZpAtUeRq8aKa+BH6qVMMoCl8ndmZrk4t43VZkpCSSsf4Gkh9xQkZVmZdMY3bOD4eVC3BEC 2VWFSY6QKabWvc8Ax3La9JxEM63qz68wXHlsBAfIP4EXKGoSNo6c1LKcUOCZgebbcXmzzC 8pyU2R9O7vhHAM+z6TIsWuNURFOf/M8= From: Usama Arif To: Rik van Riel Cc: Usama Arif , linux-kernel@vger.kernel.org, Andrew Morton , kernel-team@meta.com, David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Usama Arif Subject: Re: [PATCH RFC v3 1/6] x86/mm: add untagged_addr_remote_unlocked() Date: Mon, 20 Jul 2026 04:12:37 -0700 Message-ID: <20260720111238.3313021-1-usama.arif@linux.dev> In-Reply-To: <20260717170036.743149-2-riel@surriel.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On Fri, 17 Jul 2026 13:00:31 -0400 Rik van Riel wrote: > __access_remote_vm() reads another process's memory under the mmap lock. On > large machines that lock is contended by tasks polling /proc/PID/cmdline, > /proc/PID/environ, or calling process_vm_readv(), even though the memory > they read is almost always resident and could be reached under the per-VMA > lock instead. > > Looking up the VMA first requires untagging the address. > untagged_addr_remote() asserts the mmap lock only because it reads > mm->context.untag_mask, which can race with the write in mm_enable_lam(). > > That mask is set once, when LAM is enabled, and never changes afterwards, > so the read itself does not need the lock. It is already read without it, > from the context switch path and /proc/PID/status. > > Add untagged_addr_remote_unlocked() for callers that have not taken the > mmap lock, and annotate access to mm->context.untag_mask with READ_ONCE() > and WRITE_ONCE() so the existing lockless reads are explicit and > KCSAN-clean. untagged_addr_remote() keeps its assertion and shares the same > code. > > Assisted-by: Claude:claude-opus-4.8 > Acked-by: Usama Arif Hi Rik, Would you mind changing this to Acked-by: Usama Arif in the next revision Thanks!