From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (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 701C03F23D1 for ; Tue, 14 Jul 2026 09:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784022292; cv=none; b=K72Dtu2zrHs+w1rd2NubIYKR5iHu1B/yQSzR0wYbhSRFC5qEwWr0DxwGICdAO68vbe9arTJWRts+68KeZXG6OWbjsUnwOWn6+O4ySgYLo46qLVMBOAPldy0vOA4sHSKjDw+rLtFvfqSiLzdBuUbFgRU2ptnbPiwBpazH7heRRz0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784022292; c=relaxed/simple; bh=vdNdLux0Sfi//Ly4IoTC5BaNjMsxVtoz7V16FTw34BI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=B1dNtfBC7NNp9bo9gStP9lDykHfyfA1JAj+xV0m0MfHsdyj+GCUNZszS1Qp7jLCFyoxr0nrLeIK1V1iBeYeAZisLhXPHyrlH4yp1h3WxX9D7+3dFiOJqORW+Xc/ppFOLf08gdkCcJq6MtxBgdt++LAojpmYRwKNtDZWrrDzgSMw= 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=ICKinEcM; arc=none smtp.client-ip=91.218.175.185 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="ICKinEcM" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1784022284; 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=e+lTFxB6Ymr9p1MfVTAwXm+z+pPU7EViP2K/jOfRQ/U=; b=ICKinEcMvOthTfP0SGWhA/nWOfw/eUzMJ5vF/CD1CZ4In9N/gTDxYaFvhR4HjSbq7MTyjO xIUnhi048VZKwJvQhhZDcSml8hRKNR8lrJZuMoP1vOAzRKpD5FdK/4dkOpJXGeo0BJKNVT 8qnRq8iiR7hc1/445km7Kaeiz/O6LTw= Date: Tue, 14 Jul 2026 17:44:25 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v3 2/2] mm/mm_slot.h: add comments for mm_slot_lookup/insert To: xu.xin16@zte.com.cn, akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, ziy@nvidia.com, baolin.wang@linux.alibaba.com, baohua@kernel.org, lance.yang@linux.dev, usama.arif@linux.dev, chengming.zhou@linux.dev, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, wang.yaxin@zte.com.cn References: <20260714092815120Wv-CFDlLKtsTmda--97Qw@zte.com.cn> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Qi Zheng In-Reply-To: <20260714092815120Wv-CFDlLKtsTmda--97Qw@zte.com.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 7/14/26 9:28 AM, xu.xin16@zte.com.cn wrote: > From: xu xin > > mm_slot_lookup() and mm_slot_insert() are the only helpers in > this header that are implemented as macros rather than static inline > functions. This may look inconsistent without explanation. > > Explain they must be macros because hash_for_each_possible() > needs the table as an array (for sizeof), not a pointer. > > Signed-off-by: xu xin > --- > mm/mm_slot.h | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/mm/mm_slot.h b/mm/mm_slot.h > index 5de3e91d86b4..9b09b68e5742 100644 > --- a/mm/mm_slot.h > +++ b/mm/mm_slot.h > @@ -33,6 +33,12 @@ static inline void mm_slot_free(struct kmem_cache *cache, void *objp) > kmem_cache_free(cache, objp); > } > > +/* > + * Note: mm_slot_lookup and mm_slot_insert cannot be converted to static inline > + * functions because the hash helpers (hash_for_each_possible and hash_add) rely > + * on the actual array argument 'hashtable' for sizeof() instead of pointers. > + */ Right, that's why I wrote them as macros to begin with. Reviewed-by: Qi Zheng Thanks, Qi > + > #define mm_slot_lookup(_hashtable, _mm) \ > ({ \ > struct mm_slot *tmp_slot, *mm_slot = NULL; \