Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1883052rbb; Tue, 27 Feb 2024 04:30:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZEPc2hmxnOSIb3CnGfmTJxcmzuK1oClHB9SG9Lar3RePOQ5Hd0SIPJE0mkPPL2VRmaC2ZXMwfPIBK+52axf2oN2D21JobDBys7KuaFQ== X-Google-Smtp-Source: AGHT+IEce6LOFbX3RIChOH7ohKGFT0x23KoRMH9gSgwt92iWYL34uMu9AVPDQokxFKnDAFE9Lgic X-Received: by 2002:ac2:5ddc:0:b0:512:bead:a2a5 with SMTP id x28-20020ac25ddc000000b00512beada2a5mr5652891lfq.38.1709037004163; Tue, 27 Feb 2024 04:30:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709037004; cv=pass; d=google.com; s=arc-20160816; b=WmFMq+Apqt6r2QjFPyX0Gp1HoKF0Sebaemi9hftZx1Yskt++w6Iv59CdzZ4Npu8zIt rqNkCeH678Z3EnnjIQNiwZNW4FtvegT4GrTW6M+Px6XmTa9EmQL9vH+aAMEcTE0uphAM AVseuXtDqOOlMi+unDcqKu5gWaeR3kdGvBOE6frNYffP+Kwxf7GMZHC4FXIGuU1I0ZLo Vq7KGrQonY/QukS+DEuHVnkjz7QybXgqkJRjPQ5dat5tQIjyYY0tFMKS7j2L15XfptnV wH2khjWFRpGhEDdNW2PAaiSB4S5wccfrCB/qtfnVD0i2w5V/vlDSbjaDkTKSTSQ1rvtH C/bw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Dwit6MKXRbhy4lcJ/L0oawNcQmJYYGvK0xBm5jt1V78=; fh=HFKz53T8gNn5zCHBDpnEgmFpmncwZ100diWiAhK3T5o=; b=izpH8Y99CEpnEYZXetok5uKYVfgtBAP7VDeY/RdjzCUX/nZFz6QcrXSa5selWxU0Ju i9nVQqBPdrhH2fwjDEdbG+GRcc8wBWoLHiHkQfW5PJjg/zD6zzlwfs3mFJO0lfJov2/k /zGSLCtzkRA/0z/+EF8ZRbAgMUemMA9uqNIehefYW9IiGJincOz7V2RVRYxIFkeIG+Mm HTArrQJuJxU3kUWjyLIYJW6KG09k++j6/lmcwp4EDG6ZdMSGULG3YcpZpLFKuc0HLQnW 7K4hhXshXmEd8ParG7vIXu4dJWSyvLHhx5yblIB1W2X5VRM3aYvwu/QUHYQTwGR9NP8/ VM3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-83232-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83232-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cf30-20020a0564020b9e00b00564bcb0ece6si689913edb.235.2024.02.27.04.30.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 04:30:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83232-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-83232-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83232-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E0E341F224E2 for ; Tue, 27 Feb 2024 12:30:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF1AF13B2AD; Tue, 27 Feb 2024 12:28:31 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BDF713B2A1 for ; Tue, 27 Feb 2024 12:28:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709036911; cv=none; b=n8DR7HF1S9oKSb4V73TWjdF9E8e8o5ULvJ/bYsbcRSU18sIJjcEJtOyNC3JXD+c/xtOgRYvGN9s8b2V5do6SYAIEucIF6s8Ms6U71+o/RRhfYJWDSA6oUGkBPlqxGsu3Ra8CKMVaS5wh1I/IFNnZ8WV1BoLKR8tA3PYgK8yGbP8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709036911; c=relaxed/simple; bh=afkpinB50uAtiuEirVwsOCngi4mOGR+1dFOVwEPdmiI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FObZukNEWySzd6E9d/EoM4yXLmCQpClKMDS8kp0//ufZiLGmukgCDkxvQ3jbMDM8RT1MrH0GIAcl4ErU3BpXt1zeDW5YCN0AwoSIHKyRYFtwpDOuqnamRb9kGWrli3LGlXTXxJ21dCl+K6QVuKA7VewCSKwQRfA7FBQ3mcqy0nQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 54950DA7; Tue, 27 Feb 2024 04:29:07 -0800 (PST) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4B5403F73F; Tue, 27 Feb 2024 04:28:28 -0800 (PST) Message-ID: <9e7e3e55-1f23-4e71-90d3-83b1309b34d6@arm.com> Date: Tue, 27 Feb 2024 12:28:26 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] iommu/iova: Simplify IOVA cache allocation with KMEM_CACHE() Content-Language: en-GB To: Cong Liu , Joerg Roedel , Will Deacon Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20240227090807.82318-1-liucong2@kylinos.cn> From: Robin Murphy In-Reply-To: <20240227090807.82318-1-liucong2@kylinos.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 27/02/2024 9:08 am, Cong Liu wrote: > Use the new KMEM_CACHE() macro instead of direct kmem_cache_create > to simplify the creation of SLAB caches. Heh, this "new" macro has existed for more than half the lifetime of Linux itself ;) ...and given that users are still outnumbered at least 5:1 by users of kmem_cache_alloc(), I think it's fair to say that it hasn't really caught on all that well. Most critically, though, as I mentioned on the previous thread, this would change the userspace-visible names - where I think the "iommu_" namespace is helpful in itself - and so impact anyone who's already using meminfo to track IOVA memory consumption, so I don't think such disruption is worthwhile just to save a mere 3 lines of code. Thanks, Robin. > Signed-off-by: Cong Liu > --- > drivers/iommu/iova.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c > index d59d0ea2fd21..9134acae76f5 100644 > --- a/drivers/iommu/iova.c > +++ b/drivers/iommu/iova.c > @@ -950,14 +950,11 @@ int iova_cache_get(void) > > mutex_lock(&iova_cache_mutex); > if (!iova_cache_users) { > - iova_cache = kmem_cache_create("iommu_iova", sizeof(struct iova), 0, > - SLAB_HWCACHE_ALIGN, NULL); > + iova_cache = KMEM_CACHE(iova, SLAB_HWCACHE_ALIGN); > if (!iova_cache) > goto out_err; > > - iova_magazine_cache = kmem_cache_create("iommu_iova_magazine", > - sizeof(struct iova_magazine), > - 0, SLAB_HWCACHE_ALIGN, NULL); > + iova_magazine_cache = KMEM_CACHE(iova_magazine, SLAB_HWCACHE_ALIGN); > if (!iova_magazine_cache) > goto out_err; >