Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2279381rdb; Fri, 8 Dec 2023 03:53:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4Tln7DXoEJoBZFkFanikq0uJjDvQt/sQCsROXCnTHV6GuYU97Ng2yRaXdZqRscR90Pm9r X-Received: by 2002:a05:6a00:cc9:b0:6ce:2731:47b4 with SMTP id b9-20020a056a000cc900b006ce273147b4mr1112815pfv.20.1702036387746; Fri, 08 Dec 2023 03:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702036387; cv=none; d=google.com; s=arc-20160816; b=NLcqQ7TnhQustjn/AdUvDNQozYur1sTVJZFW/5LeMtV3LDld20n8OLVix+/G2jpwLD MYfCHK4B/ApfFbCPlcdOgnZ7GonaDNOdl/Nl0XmH397Y2A505mbZNVd6JxWkZeTdVFMn 7q6G0U+x9ZrR6CXXUZq+eZA3Llf2NMiMCgcydqxvZYXJu4XZT3esAwINsDaPAqBmsGfW SQ/1qLTao3FRhM4nnlwv9Sp+19FyjRSIRKRqMrc2SXr8Cz8GD3jS7hKd/kn4MGrKDqXo OBlrw85rHx3l/mNCTgzGfDjb/EBytVyx9B/nk9ZP8xaVp+V6GYkDNTbBFAYgV82ZjwUM lVQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=+Bzhtr8Z/zHR1SS9qrv2WMjasbEmV2BoWGNIe8Z1tRg=; fh=ul8mmpcsIC6lZrb4xZroilYF4KwdwF2vyiWKtklDXsc=; b=j6vJA+ITrk8oVXTP5JwO4X/Qm2lAhCXwfJNuIoKBXItlAXWzToymdkxgkb9uSFHLa5 ZW1CGckt6ipASinOOGSOfFeueZ9jeqe7QakHVi43WQM0dNaVONSs82dhha/FEmIMhqyy LoM5+dzEO8ML5I+vraWQgHI/x92QJdfFFyGx1qmhRJWAsx+zsvLsvJ/3TuQ+9mpy6/IE Z0jDX8wgA1kBHj8SGHnJ9qWIEj9LyWHeycdbY7+96/shrC8Vx8MeI/xJD3b6syjlOGpy sAiIqX4A2ckgH0gEhlAEtqNSmSaTEOoxPuek8jH1E9rr6qLeBeGZXA5F6Zwe9UqrYGI2 utwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pmjuKESv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id o16-20020a056a00215000b006ce4207c516si1411073pfk.388.2023.12.08.03.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 03:53:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pmjuKESv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 78504807DEDB; Fri, 8 Dec 2023 03:53:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573540AbjLHLws (ORCPT + 99 others); Fri, 8 Dec 2023 06:52:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233505AbjLHLwq (ORCPT ); Fri, 8 Dec 2023 06:52:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBE11171F; Fri, 8 Dec 2023 03:52:51 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702036369; 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=+Bzhtr8Z/zHR1SS9qrv2WMjasbEmV2BoWGNIe8Z1tRg=; b=pmjuKESv4alxlWy9xXV/apAlv4xR7VxTUs7pAvw6l4veAR6iQbL83UpOdjpY/obRJdLcfo 34PRGPNv5BVBMAhFccxAlq9bBigrkpWfoOBs9VEes7vF1akDLgK/JGE4Mxq0ZzCJVISx5l I/dDrPJqVDTtIbL53jyZ+zfZsY4ml/z0eQuZhLdJmsXO5togc6bPvyGnUQgHVXY/inOziR MDetaqoIKi0ESx77qQNtGyhDYIQsv7+Io2/KhThR5FzP3k8xcZxBFkr13T4U9GR6xW1NOY gf+6L4rqZwU7QHAmqMpzi0g3buykKehh/LFn88D+42VGaMV3BXqV805cQ4YHEw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702036369; 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=+Bzhtr8Z/zHR1SS9qrv2WMjasbEmV2BoWGNIe8Z1tRg=; b=pS7ZGZq8uhbuePRlfYDITaiZxhff8pz3xaspEarOeSXWmtVmjO0shwgy4CuY4Dk5GJcri4 h5Utb4ZE5vc+OqDQ== To: Jacob Pan Cc: Peter Zijlstra , LKML , X86 Kernel , iommu@lists.linux.dev, Lu Baolu , kvm@vger.kernel.org, Dave Hansen , Joerg Roedel , "H. Peter Anvin" , Borislav Petkov , Ingo Molnar , Raj Ashok , "Tian, Kevin" , maz@kernel.org, seanjc@google.com, Robin Murphy , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH RFC 09/13] x86/irq: Install posted MSI notification handler In-Reply-To: <20231207204607.2d2a3b72@jacob-builder> References: <20231112041643.2868316-1-jacob.jun.pan@linux.intel.com> <20231112041643.2868316-10-jacob.jun.pan@linux.intel.com> <20231115125624.GF3818@noisy.programming.kicks-ass.net> <87cyvjun3z.ffs@tglx> <20231207204607.2d2a3b72@jacob-builder> Date: Fri, 08 Dec 2023 12:52:49 +0100 Message-ID: <87zfyksyge.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 08 Dec 2023 03:53:04 -0800 (PST) On Thu, Dec 07 2023 at 20:46, Jacob Pan wrote: > On Wed, 06 Dec 2023 20:50:24 +0100, Thomas Gleixner > wrote: >> I don't understand what the whole copy business is about. It's >> absolutely not required. > > My thinking is the following: > The PIR cache line is contended by between CPU and IOMMU, where CPU can > access PIR much faster. Nevertheless, when IOMMU does atomic swap of the > PID (PIR included), L1 cache gets evicted. Subsequent CPU read or xchg will > deal with invalid cold cache. > > By making a copy of PIR as quickly as possible and clearing PIR with xchg, > we minimized the chance that IOMMU does atomic swap in the middle. > Therefore, having less L1D misses. > > In the code above, it does read, xchg, and call_irq_handler() in a loop > to handle the 4 64bit PIR bits at a time. IOMMU has a greater chance to do > atomic xchg on the PIR cache line while doing call_irq_handler(). Therefore, > it causes more L1D misses. That makes sense and if we go there it wants to be documented. > Without PIR copy: > > DMA memfill bandwidth: 4.944 Gbps > Performance counter stats for './run_intr.sh 512 30': > > 77,313,298,506 L1-dcache-loads (79.98%) > 8,279,458 L1-dcache-load-misses # 0.01% of all L1-dcache accesses (80.03%) > 41,654,221,245 L1-dcache-stores (80.01%) > 10,476 LLC-load-misses # 0.31% of all LL-cache accesses (79.99%) > 3,332,748 LLC-loads (80.00%) > > 30.212055434 seconds time elapsed > > 0.002149000 seconds user > 30.183292000 seconds sys > > > With PIR copy: > DMA memfill bandwidth: 5.029 Gbps > Performance counter stats for './run_intr.sh 512 30': > > 78,327,247,423 L1-dcache-loads (80.01%) > 7,762,311 L1-dcache-load-misses # 0.01% of all L1-dcache accesses (80.01%) > 42,203,221,466 L1-dcache-stores (79.99%) > 23,691 LLC-load-misses # 0.67% of all LL-cache accesses (80.01%) > 3,561,890 LLC-loads (80.00%) > > 30.201065706 seconds time elapsed > > 0.005950000 seconds user > 30.167885000 seconds sys Interesting, though I'm not really convinced that this DMA memfill microbenchmark resembles real work loads. Did you test with something realistic, e.g. storage or networking, too? Thanks, tglx