From patchwork Tue Dec 3 19:15:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13892824 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 B08C71FDE05 for ; Tue, 3 Dec 2024 19:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733253438; cv=none; b=UHrz4cey1R4xdKRKgvk8HQfg9ok0SXwi8J7bQnYobBg6QSV562iwjoI45Km/2KwEEaN1wFlTQv/mlmz62sFY7a6aqGyREmcSj027igNbZIcigw4Xl9Vmt2vGFfxH97X5R4dEIc54Q/Uu3/8vSB70dSghCiSdiUgbItWra6ij4HQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733253438; c=relaxed/simple; bh=H/1gr4VaKNoGODypChOGc4OjXFVLRq837Q3U63BqhFs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eRSeuGTaqJMhgqsGdfAkuHJ3IqssB4zhhPhawviHBJhp4Wf+BCrSnPdVu6k2H0nqY5voqIBohLtAy4doEQ+NCSFAB58d03wzV4M5m7878ULawZaS7Ahd4K41scXcDfTaT9w++JjoeD8PmOHlCb+aDiIf6J7WWW0d6aJ58hjHIts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=H+AryZE0; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="H+AryZE0" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B3HtXWK006127; Tue, 3 Dec 2024 19:17:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2023-11-20; bh=8V8VB cnUEQPnkibYRDceX41FTQxdvQE9Earg84J5Gkc=; b=H+AryZE0+/xH+FYQgsPN3 Cd4Ie7kaP8SmrcrTFZEZqPm8VC4x+DFCKWsFG8EW8K66E5ObC/Ij1EVvtvb9Gcp0 ipJfPP1P+mnIs5uv7RYywNcdKOWlxaijbHHLZaHRd1WHKBXiS+UBP4ZZg0kg1s8L tAlpSN0VxaQvf+RWic7usgo22cjig5z7n4DM3mrevMyNMkE2kQuLwTPSz3HNQxQw yOnszXXtxnw4Fs1pGPQp3V0bVoqaN4MZOFzTfiUC+2fDJAMz5JSIluBdfVrL3noP FNCU0coJUYL5D48syqZP/+dJCL+aurqkBv5s1czYVd/9tA5XGWVF1qe1UZcKmRQa A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 437trbpw22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Dec 2024 19:17:12 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4B3JAiOc001877; Tue, 3 Dec 2024 19:17:11 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 437s58akct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Dec 2024 19:17:11 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4B3JH9MC021603; Tue, 3 Dec 2024 19:17:11 GMT Received: from mnc-mac.us.oracle.com (dhcp-10-65-163-31.vpn.oracle.com [10.65.163.31]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 437s58ak94-3; Tue, 03 Dec 2024 19:17:11 +0000 From: Mike Christie To: stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, pbonzini@redhat.com, target-devel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH v2 2/8] vhost-scsi: Allocate T10 PI structs only when enabled Date: Tue, 3 Dec 2024 13:15:09 -0600 Message-ID: <20241203191705.19431-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241203191705.19431-1-michael.christie@oracle.com> References: <20241203191705.19431-1-michael.christie@oracle.com> Precedence: bulk X-Mailing-List: target-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-03_08,2024-12-03_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412030159 X-Proofpoint-GUID: jLToRsmT4qXtFBbh-InWIOzODuV0fRAH X-Proofpoint-ORIG-GUID: jLToRsmT4qXtFBbh-InWIOzODuV0fRAH T10 PI is not a widely used feature. This has us only allocate the structs for it if the feature has been enabled. For a common small setup where you have 1 virtqueue and 128 commands per queue, this saves: 8MB = 32 bytes per sg * 2048 entries * 128 commands per vhost-scsi device. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index adb3cd47b4e3..99e008219e6c 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1651,12 +1651,14 @@ static int vhost_scsi_setup_vq_cmds(struct vhost_virtqueue *vq, int max_cmds) goto out; } - tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS, - sizeof(struct scatterlist), - GFP_KERNEL); - if (!tv_cmd->tvc_prot_sgl) { - pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n"); - goto out; + if (vhost_has_feature(vq, VIRTIO_SCSI_F_T10_PI)) { + tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS, + sizeof(struct scatterlist), + GFP_KERNEL); + if (!tv_cmd->tvc_prot_sgl) { + pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n"); + goto out; + } } } return 0;