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 2550814D6F6 for ; Mon, 13 Jan 2025 04:22:13 +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=1736742134; cv=none; b=MlJZ9PbUuTPm+PJxWdX7udzQjG/NHP/JPuU0tMmw2flO/21Igl96QBHQ82nXBfiQDUW2MnFyQxjjf0k9laYr+I4aY/EXUPzvDDECxlYcp4T4qQaQQLJPiKyHVF+TrOZQTHzWKTSxFUQ5W2FRHkmp+nfcl6gip9Wb8hFOsUFHBqE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736742134; c=relaxed/simple; bh=DCuxXlQXbBoVd9alC+ueLm1tRc0MoBUtT9ar9V29+mM=; h=Date:To:From:Subject:Message-Id; b=MJRVgJJ5qfJfG9Fjgz6e8a0zzossX86ClHEeGeyJgqrR2A5NTu/QAuzL8WAjQC9549s+/yQJZrvSE502ytITAdRRTWoF7P5M8K/vBmtJXL7NOml9Iaffw7W9+Q4kpcGMPrvAx54RKNEGrpzADPXmpk4Bpe/WAFzlyU2kEQh6SvE= 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=SzjmxdGL; 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="SzjmxdGL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A439C4CED6; Mon, 13 Jan 2025 04:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1736742133; bh=DCuxXlQXbBoVd9alC+ueLm1tRc0MoBUtT9ar9V29+mM=; h=Date:To:From:Subject:From; b=SzjmxdGLLWLN1o//pVweQsd7VgkoapPyPy83qL9CSnJCGepguB8KG7thqqT34OcEH Xbg9hBfSyFt+7R2FhAqxSR97HPVUd5S7T1qx0y2IQplSG98R4QGGGBgOKXKunKtcRm A0wGfCn5JFN/Dp5q/FrwauYRqxZYKLj+siiNF3+o= Date: Sun, 12 Jan 2025 20:22:13 -0800 To: mm-commits@vger.kernel.org,willy@infradead.org,aliceryhl@google.com,a.hindborg@kernel.org,tamird@gmail.com,akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-nonmm-stable] xarray-extract-xa_zero_to_null.patch removed from -mm tree Message-Id: <20250113042213.8A439C4CED6@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The quilt patch titled Subject: xarray: extract xa_zero_to_null has been removed from the -mm tree. Its filename was xarray-extract-xa_zero_to_null.patch This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Tamir Duberstein Subject: xarray: extract xa_zero_to_null Date: Tue, 12 Nov 2024 14:25:36 -0500 Patch series "xarray: extract __xa_cmpxchg_raw". This series reduces duplication between __xa_cmpxchg and __xa_insert by extracting a new function that does not coerce zero entries to null on the return path. The new function may be used by the upcoming Rust xarray abstraction in its reservation API where it is useful to tell the difference between zero entries and null slots. This patch (of 2): Reduce code duplication by extracting a static inline function that returns its argument if it is non-zero and NULL otherwise. This changes xas_result to check for errors before checking for zero but this cannot change the behavior of existing callers: - __xa_erase: passes the result of xas_store(_, NULL) which cannot fail. - __xa_store: passes the result of xas_store(_, entry) which may fail. xas_store calls xas_create when entry is not NULL which returns NULL on error, which is immediately checked. This should not change observable behavior. - __xa_cmpxchg: passes the result of xas_load(_) which might be zero. This would previously return NULL regardless of the outcome of xas_store but xas_store cannot fail if xas_load returns zero because there is no need to allocate memory. - xa_store_range: same as __xa_erase. Link: https://lkml.kernel.org/r/20241112-xarray-insert-cmpxchg-v1-0-dc2bdd8c4136@gmail.com Link: https://lkml.kernel.org/r/20241112-xarray-insert-cmpxchg-v1-1-dc2bdd8c4136@gmail.com Signed-off-by: Tamir Duberstein Cc: Alice Ryhl Cc: Andreas Hindborg Cc: Matthew Wilcox Signed-off-by: Andrew Morton --- lib/xarray.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) --- a/lib/xarray.c~xarray-extract-xa_zero_to_null +++ a/lib/xarray.c @@ -435,6 +435,11 @@ static unsigned long max_index(void *ent return (XA_CHUNK_SIZE << xa_to_node(entry)->shift) - 1; } +static inline void *xa_zero_to_null(void *entry) +{ + return xa_is_zero(entry) ? NULL : entry; +} + static void xas_shrink(struct xa_state *xas) { struct xarray *xa = xas->xa; @@ -451,8 +456,8 @@ static void xas_shrink(struct xa_state * break; if (!xa_is_node(entry) && node->shift) break; - if (xa_is_zero(entry) && xa_zero_busy(xa)) - entry = NULL; + if (xa_zero_busy(xa)) + entry = xa_zero_to_null(entry); xas->xa_node = XAS_BOUNDS; RCU_INIT_POINTER(xa->xa_head, entry); @@ -1474,9 +1479,7 @@ void *xa_load(struct xarray *xa, unsigne rcu_read_lock(); do { - entry = xas_load(&xas); - if (xa_is_zero(entry)) - entry = NULL; + entry = xa_zero_to_null(xas_load(&xas)); } while (xas_retry(&xas, entry)); rcu_read_unlock(); @@ -1486,11 +1489,9 @@ EXPORT_SYMBOL(xa_load); static void *xas_result(struct xa_state *xas, void *curr) { - if (xa_is_zero(curr)) - return NULL; if (xas_error(xas)) curr = xas->xa_node; - return curr; + return xa_zero_to_null(curr); } /** _ Patches currently in -mm which might be from tamird@gmail.com are