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 F349645EF3; Fri, 20 Dec 2024 05:59:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7130440267; Fri, 20 Dec 2024 05:59:58 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id E501140144 for ; Fri, 20 Dec 2024 05:59:56 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7ee11ff7210so1106598a12.1 for ; Thu, 19 Dec 2024 20:59:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1734670796; x=1735275596; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=MnEngEivVTHM2bAoGsEGHIg8ZeHnE06VTyKObrbdwiY=; b=anb9g/IN7uWygzvq4ITce08CrddH0fc2F68Pjo2MuTKd7Gs1jATIKDPX78DbnlAE3N HIeg+kpiN6NepviiTJ/xEC9ySuCMqixJHCrioNVenFS4b6oDvrSVeFf2QG89u8rwTM7G Ha/y+huYcUUT9M9injd6MQzHlpVRqlduOj3ap1lAWWcyRqoEOGB/WnRPA7Mh0KYhISyf fbgepJR7qphD8qIAg7XLn7Dpin8xuNL+NqG1hU87I7G3PY/eGgx6Drm/NbPpaSSRDNgh naiO6vWCU89NR5f5CF17HgFRTQZrP4uZCPf6FbJViCT9jD/CGhQ6e2d/qZFXems/D01A vFmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734670796; x=1735275596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MnEngEivVTHM2bAoGsEGHIg8ZeHnE06VTyKObrbdwiY=; b=GnefXoKyVdI4eQNWuX9YfmlkvDO6Jv8I0pPVYib3009KdMQi/Xdxe/BpdXlOOW4aB2 F7H3/yTsFDGD7c57RJcQcm9h/xIWEjn+iT6+jxb2uVGfmAO7S0HH4YIo1HOZiZHnTMgc 5udd27GYbv63+pnKCBY6vvqjv0lbYkRKakC+udr1Pg7HnPSC0mz5MeqLPZnmD/CEiEVH XbmQxOb0c3FyTS7X4xDuq3EP0Pv3VRIHLMwjFJkDCBfywdASPiO3Y2j4BITX8sBxC7Z1 WXRorEHeCZW407SRHph13X0ctPTn04Gn9NO7GWviqetbgg5zHb6ghTjxCqe0FVXGcHv3 2I0g== X-Gm-Message-State: AOJu0YxLNvjlwCb/I2dxD1lmNttldb0R/l+8mGHZswNxaVt/LmRAbp60 e3ZsCE+DKt3Q5asHeG7FFkhmnj9iZnSv6wAons6oAj0lfseW7RiiYR9YItoMUBg= X-Gm-Gg: ASbGnctWVa3zi0lC08a7y1YfPzqJTrv+Fs4dSQFzS0KiLKvW71C/6rWfqGoJSLkWU9l uD9Y3jtCTxcd7B/37J915T6TQ573fSlXM1HrqAtQ+mPjmYpzAi79TYCiA2KXp0ldmE3hHdTrasl GfclsUUnNJuxnEoHLDzBk1XjDu1lqZrVqTMDWbixsUDJiplyRgH7z7z+nkBo2yqc/lqZMrxLcFo 97U5crrOMsJdLFBHUUY9rfjtKFSpHoj2UnWMcXdTNGkD3FG36plG0ssZIDUISStziVLd2sbTbP+ Dvj7rsZxIilljajHz/bV5U4rNA7B4w1ncA== X-Google-Smtp-Source: AGHT+IECZgOYZ4EmDBmjBaIN2g9qZmvegQJDiLSZF1F7KskAZ9znKP867z5FzGfTWQLeMw/vHU0ASQ== X-Received: by 2002:a05:6a21:998b:b0:1e0:b5ae:8fc1 with SMTP id adf61e73a8af0-1e5e0484570mr2671942637.13.1734670795845; Thu, 19 Dec 2024 20:59:55 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b84fb8ddsm2033647a12.42.2024.12.19.20.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 20:59:55 -0800 (PST) Date: Thu, 19 Dec 2024 20:59:52 -0800 From: Stephen Hemminger To: "Wangyunjian(wangyunjian,TongTu)" Cc: "dev@dpdk.org" , "maxime.coquelin@redhat.com" , "chenbox@nvidia.com" , "Lilijun (Jerry)" , "xiawei (H)" , wangzengyuan , "stable@dpdk.org" Subject: Re: [PATCH 1/1] vhost: fix a double fetch when dequeue offloading Message-ID: <20241219205952.08c09ae7@hermes.local> In-Reply-To: References: <91dc12662805a3867413940f856ba9454b91c579.1734588243.git.wangyunjian@huawei.com> <20241219081532.345c7536@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, 20 Dec 2024 02:17:12 +0000 "Wangyunjian(wangyunjian,TongTu)" wrote: > > -----Original Message----- > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > Sent: Friday, December 20, 2024 12:16 AM > > To: Wangyunjian(wangyunjian,TongTu) > > Cc: dev@dpdk.org; maxime.coquelin@redhat.com; chenbox@nvidia.com; > > Lilijun (Jerry) ; xiawei (H) ; > > wangzengyuan ; stable@dpdk.org > > Subject: Re: [PATCH 1/1] vhost: fix a double fetch when dequeue offloading > > > > On Thu, 19 Dec 2024 14:38:28 +0800 > > Yunjian Wang wrote: > > > > > - hdr = (struct virtio_net_hdr *)((uintptr_t)buf_vec[0].buf_addr); > > > + rte_memcpy((void *)(uintptr_t)&tmp_hdr, > > > + (void *)(uintptr_t)buf_vec[0].buf_addr, > > > + sizeof(struct virtio_net_hdr)); > > > } > > > > Do not introduce more rte_memcpy of a fixed size. > > You don't need that many casts! > > Why can you not use a structure assignment here. > > The virtio_hdr is a shared component, and other fields within it are read > multiple times. This can potentially result in a double fetch scenario. The point is do a copy, but not with rte_memcpy. Also you need a rte_compiler_barrier() anyway.