From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5A56F455AD for ; Mon, 15 Jul 2024 17:27:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 55760406B4; Mon, 15 Jul 2024 17:27:15 +0200 (CEST) Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mails.dpdk.org (Postfix) with ESMTP id A967B402B0 for ; Mon, 15 Jul 2024 17:27:13 +0200 (CEST) Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-367a3d1a378so4013922f8f.1 for ; Mon, 15 Jul 2024 08:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721057233; x=1721662033; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5r8n8aMvR2VWvykskfAJcfjqgcliz2MmY2wR0cOboo8=; b=AcWq4zjFdAESmO2yohj/vQBifzLj5ZeeoJ0BTb8kSyD5nDo3NFLNr4rhiqk5n2/NwK q0AqW1qz0WCzKXyzmD8/JWPxKyX/p/vCbhgpizCudERi2SC+SO5Y5hCqza0KroBnNI2h HBm/7VUvAsqO6LnHEVjocIy5oyF0SPHTBVAFbu3OYEgRmP3ufsahq7uQmY+SJhopQNY6 U37v4FM97BdB7k0oAWKOTnh7EIcCh60m9l1fe/DP3a8wVe5Hu+X1U/JedLF+4Galjso2 MOcS2NXnyEq+RV4TVN4iH70Wg/nyWNYkm5Y2/yuXqylvns2Ccm6RRp/cVTu9RHXEAbiz pEag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721057233; x=1721662033; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5r8n8aMvR2VWvykskfAJcfjqgcliz2MmY2wR0cOboo8=; b=tFnMYTO2lctVEb13p2EmIsqzdmvKwjzuQXHubtA02hcwDD7NpfZdXYub8jCDCg1Okq oGkMSR0BGHV0vOVtXmMYcKXwP0hhFOsoOqlzl/PRUHDbzze/VosaWDM9tpXxJ5X+AFfs pL/BwjVytJx1TOR9RBryCN1njYXaI4qMALq7BBCpRAbOML57S78ImdgRVCD5dkAQGRyW CjGgxsVyVsBZrsRZX17UWK4FtYx1u8r22zn2FCeHOrchsWnUgboDJUz0QdLfoWX9U3eZ 2sGh0uD5JsA56lJ6aPv1ZQwm0CSgj9zvMvDcE/nm6yXUnHOmqD1x2yCZ32V5pIObdgsa 1aag== X-Forwarded-Encrypted: i=1; AJvYcCXN1QUM6r+dMupLJTQSsz19IGmWIMScFcqwmp/Z4EBo1bRbb6Y+Q7XT+GwmXzNHCGBQnhyBCHxBsg9tSIPfY/Y= X-Gm-Message-State: AOJu0YzmBYBcTyrScqxTO+KEi2G/1+Myg2ojs+8LAbumBBFWebFPWEPL WE9bidszTT6ILHAqlFzGgb66tcLwRiHQiA4krySg/zFYgl2SaSRf X-Google-Smtp-Source: AGHT+IHOhJX03zmNFX0B9zyWUYTHhikwW1924g+9LaFm6PzultxMil7+ZaXUXGWN2geYNZrmBwzYbw== X-Received: by 2002:adf:ea04:0:b0:367:9881:7d5f with SMTP id ffacd0b85a97d-36824078925mr86041f8f.3.1721057233292; Mon, 15 Jul 2024 08:27:13 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:7aef:1aaa:3dff:d546]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dabf0bfsm6665340f8f.31.2024.07.15.08.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 08:27:12 -0700 (PDT) From: luca.boccassi@gmail.com To: Wenwu Ma Cc: Chengwen Feng , dpdk stable Subject: patch 'dmadev: fix structure alignment' has been queued to stable release 22.11.6 Date: Mon, 15 Jul 2024 16:25:42 +0100 Message-Id: <20240715152704.2229503-4-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240715152704.2229503-1-luca.boccassi@gmail.com> References: <20240624235907.885628-81-luca.boccassi@gmail.com> <20240715152704.2229503-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/17/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/e35ccc8804b944595fa531f69b48c5f240dad59e Thanks. Luca Boccassi --- >From e35ccc8804b944595fa531f69b48c5f240dad59e Mon Sep 17 00:00:00 2001 From: Wenwu Ma Date: Wed, 20 Mar 2024 15:23:32 +0800 Subject: [PATCH] dmadev: fix structure alignment [ upstream commit c15902587b538ff02cfb0fbb4dd481f1503d936b ] The structure rte_dma_dev needs to be aligned to the cache line, but the return value of malloc may not be aligned to the cache line. When we use memset to clear the rte_dma_dev object, it may cause a segmentation fault in clang-x86-platform. This is because clang uses the "vmovaps" assembly instruction for memset, which requires that the operands (rte_dma_dev objects) must aligned on a 16-byte boundary or a general-protection exception (#GP) is generated. Therefore, either additional memory is applied for re-alignment, or the rte_dma_dev object does not require cache line alignment. The patch chooses the former option to fix the issue. Fixes: b36970f2e13e ("dmadev: introduce DMA device library") Signed-off-by: Wenwu Ma Reviewed-by: Chengwen Feng --- lib/dmadev/rte_dmadev.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index b48b915edc..d94f85ea9a 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -157,15 +157,24 @@ static int dma_dev_data_prepare(void) { size_t size; + void *ptr; if (rte_dma_devices != NULL) return 0; - size = dma_devices_max * sizeof(struct rte_dma_dev); - rte_dma_devices = malloc(size); - if (rte_dma_devices == NULL) + /* The DMA device object is expected to align cacheline, + * but the return value of malloc may not be aligned to the cache line. + * Therefore, extra memory is applied for realignment. + * Note: posix_memalign/aligned_alloc are not used + * because not always available, depending on libc. + */ + size = dma_devices_max * sizeof(struct rte_dma_dev) + RTE_CACHE_LINE_SIZE; + ptr = malloc(size); + if (ptr == NULL) return -ENOMEM; - memset(rte_dma_devices, 0, size); + memset(ptr, 0, size); + + rte_dma_devices = RTE_PTR_ALIGN(ptr, RTE_CACHE_LINE_SIZE); return 0; } -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-15 16:19:34.992740818 +0100 +++ 0004-dmadev-fix-structure-alignment.patch 2024-07-15 16:19:34.440203731 +0100 @@ -1 +1 @@ -From c15902587b538ff02cfb0fbb4dd481f1503d936b Mon Sep 17 00:00:00 2001 +From e35ccc8804b944595fa531f69b48c5f240dad59e Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit c15902587b538ff02cfb0fbb4dd481f1503d936b ] + @@ -21 +22,0 @@ -Cc: stable@dpdk.org @@ -30 +31 @@ -index e64b279bac..845727210f 100644 +index b48b915edc..d94f85ea9a 100644 @@ -33 +34 @@ -@@ -159,15 +159,24 @@ static int +@@ -157,15 +157,24 @@ static int