From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 012D0D53B for ; Sat, 3 Aug 2024 12:39:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722688789; cv=none; b=GXBZYfw9Fjxi1ppBlrnKKAGVToTQcIgMR3dFLBhE35hJKXuEN/oIIIO+KCVLdgo1iOKDqQC1AfB1aZtPVQB1qyUtFSGBGLokqn+4Y5C3JHtYZoFLJiIYJJ/2KCVGwetEFJFXmzEsBiOuN45WT6D4c2R9EnlOhlTg9Y1XV1t+pDo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722688789; c=relaxed/simple; bh=gD2FpfB39EnjPLFzGX1h9zd6wgd7sajf8+31wkVyNEM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: In-Reply-To:Content-Type:Content-Disposition; b=MtFvM7Nd6ymKpFb9fgEBkefPOJfbDicio39AJiMsuJwUscIiRGWtqSABf/qdDoBe/qZiIcE+3hR/VgchYhOinLji9C2hoIBRE2mBjGN4CuPl1iP/M6bOJl9bzTXlBdibQQc0wzlr0gFyk7JKXefqJexZrEdhBWjmce4CMrgCgd8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=G5foG/q0; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G5foG/q0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722688785; 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: in-reply-to:in-reply-to:references:references; bh=bud4nRKRklECKnm96ltuCrae8m0qJHJoxUo8AttxE8U=; b=G5foG/q0WlT+tCXXk3WnerCZrBytWinnjqC73jtejLIZ33E9ORKYXjxrNfRVHoXy5i1cBU KW+CWSVFHrZBivbpshuVq8jTa2vrXV5ahNXKX2yTTS2l6M4pZmocuXdE76dd9TRTLi5Twz tqqWR7jjBUwBaHUWoJEPI7SiNsz3giI= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-jGzBka6kPZuAKhU-wM5n0g-1; Sat, 03 Aug 2024 08:39:44 -0400 X-MC-Unique: jGzBka6kPZuAKhU-wM5n0g-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-427b7a2052bso86985755e9.2 for ; Sat, 03 Aug 2024 05:39:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722688783; x=1723293583; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bud4nRKRklECKnm96ltuCrae8m0qJHJoxUo8AttxE8U=; b=UuZNVh9UgQA4YxQFvipocb157Kn2PsUM33FiPTX6gHikrTJOPpLBZIdD8mKYgxIMKM laPROc5bW5hCUplDNs1Ef2l8RQmPNvhnXCmu0f32cYmQE0QyoNrtqhOjcL3kw+Ya/Y9i e8sW/DLi6Y9nmXdUV91q+kRp2ugLvr3bEEADZV+suAbQ7ORPgjtTtZWPuey9wS6I9cFc 5mVbGxft2+yxbaedQ+62QGENnbuk+ZV3450TsWSCBNCpv9nSGD2kG0vfMsyUBWd2x8Ch SP7kmHQXgQpTlr1eMEK0vkA0DEEqZfF0Lg2/s5W9ldARq4vvLcQZfuFjQD+jTEhoYsWq PaIg== X-Forwarded-Encrypted: i=1; AJvYcCWePddxSPp3dGcZ8RvrObWDW1OAXd331av7R5YAHFD/2ejefhaX/qfHwPzUelk5yn+UehCW9wQmYf4XKKgDQrO2GX+xFo+J1C7LUrgCEBs= X-Gm-Message-State: AOJu0YzSCfDkkDnuBligFYy8Kr/E3QDvgVw/2V83exlH8orhU7U9xMz4 KdmsfDkh7Wn5MEpt/6/L/4MAm90Ah9dd3EsBpbo52YEbro4Oyv/dDGp17/SGL6VvuFVzZFmRSzl jUud10Nt8ASpGlYnfwDC0A8WRUcg+dGMdSM3grIKdyIqa92318pLLMk8klccocufO X-Received: by 2002:a05:600c:46d5:b0:428:e820:37b6 with SMTP id 5b1f17b1804b1-428e8203ceamr44618485e9.31.1722688783174; Sat, 03 Aug 2024 05:39:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHztpDlicRIdPi/ph07KPQz9rUp5hL3ZffxDp857thGb8EBxST2h/nU6rQ6f3ID+f0aHwyskA== X-Received: by 2002:a05:600c:46d5:b0:428:e820:37b6 with SMTP id 5b1f17b1804b1-428e8203ceamr44618275e9.31.1722688782353; Sat, 03 Aug 2024 05:39:42 -0700 (PDT) Received: from redhat.com ([2a06:c701:743c:ac00:6ba3:915a:fea:a61d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4282b89a862sm127450475e9.4.2024.08.03.05.39.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Aug 2024 05:39:41 -0700 (PDT) Date: Sat, 3 Aug 2024 08:39:38 -0400 From: "Michael S. Tsirkin" To: Max Gurtovoy Cc: Stefan Hajnoczi , virtualization@lists.linux.dev, axboe@kernel.dk, kvm@vger.kernel.org, linux-block@vger.kernel.org, oren@nvidia.com Subject: Re: [PATCH 1/1] virtio_blk: implement init_hctx MQ operation Message-ID: <20240803083824-mutt-send-email-mst@kernel.org> References: <20240801151137.14430-1-mgurtovoy@nvidia.com> <20240801111337-mutt-send-email-mst@kernel.org> <0888da3b-3283-405b-b1a8-a315e2623289@nvidia.com> <20240801112843-mutt-send-email-mst@kernel.org> <9400fb28-47c2-4629-af17-df2a95f2d3d8@nvidia.com> <20240801114205-mutt-send-email-mst@kernel.org> <6a8f0c72-ba77-42c3-8d85-6bb23a23f025@nvidia.com> <20240801175617.GA1133773@fedora.redhat.com> Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Aug 03, 2024 at 01:07:27AM +0300, Max Gurtovoy wrote: > > On 01/08/2024 20:56, Stefan Hajnoczi wrote: > > On Thu, Aug 01, 2024 at 06:56:44PM +0300, Max Gurtovoy wrote: > > > On 01/08/2024 18:43, Michael S. Tsirkin wrote: > > > > On Thu, Aug 01, 2024 at 06:39:16PM +0300, Max Gurtovoy wrote: > > > > > On 01/08/2024 18:29, Michael S. Tsirkin wrote: > > > > > > On Thu, Aug 01, 2024 at 06:17:21PM +0300, Max Gurtovoy wrote: > > > > > > > On 01/08/2024 18:13, Michael S. Tsirkin wrote: > > > > > > > > On Thu, Aug 01, 2024 at 06:11:37PM +0300, Max Gurtovoy wrote: > > > > > > > > > In this operation set the driver data of the hctx to point to the virtio > > > > > > > > > block queue. By doing so, we can use this reference in the and reduce > > > > > > > > in the .... ? > > > > > > > sorry for the type. > > > > > > > > > > > > > > should be : > > > > > > > > > > > > > > "By doing so, we can use this reference and reduce the number of operations in the fast path." > > > > > > ok. what kind of benefit do you see with this patch? > > > > > As mentioned. This is a micro optimization that reduce the number of > > > > > instructions/dereferences in the fast path. > > > > By how much? How random code tweaks affect object code is unpredictable. > > > > Pls show results of objdump to prove it does anything > > > > useful. > > > This is the way all modern block drivers such as NVMe PCI/RDMA/TCP use the > > > driver_data. > > > > > > These drivers don't have driver specific mechanisms to find the queue from > > > the hctx->queue->queuedata like vblk driver has for some unknown reason. > > > > > > It is pretty easy to review this patch and see its benefits, isn't it ? > > > > > > It is not expected to provide extreme perf improvement. > > > > > > It is introduced for aligning the driver to use common MQ mechanisms and > > > reduce dereferences. > > > > > > This is not "random code tweaks". > > If you cannot observe a performance change, then adjusting the commit > > description to explain this as a code cleanup to reduce dereferences and > > local variables, improving code readability seems fine to me. I think > > it's a nice cleanup when presented as such rather than a performance > > optimization. > > > > Stefan > > Sure. Please check the bellow adjustment: > > virtio_blk: implement init_hctx MQ operation > > Set the driver data of the hardware context (hctx) to point directly to > the virtio block queue. This cleanup improves code readability, reduces > the number of dereferences, and minimizes local variables in the fast > path. I'd drop the local variables part, it is not at all clear why is that a win. -- MST