Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2222217/?format=api
{ "id": 2222217, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2222217/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/87ik9yzg9g.ffs@tglx/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/1.1/projects/2/?format=api", "name": "Linux PPC development", "link_name": "linuxppc-dev", "list_id": "linuxppc-dev.lists.ozlabs.org", "list_email": "linuxppc-dev@lists.ozlabs.org", "web_url": "https://github.com/linuxppc/wiki/wiki", "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git", "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/" }, "msgid": "<87ik9yzg9g.ffs@tglx>", "date": "2026-04-10T20:56:11", "name": "[V1.1,11/38] misc: sgi-gru: Remove get_cycles() [ab]use", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "a8da5805f98eea1ab3b68b8d57715dc93c5e1333", "submitter": { "id": 92397, "url": "http://patchwork.ozlabs.org/api/1.1/people/92397/?format=api", "name": "Thomas Gleixner", "email": "tglx@kernel.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/87ik9yzg9g.ffs@tglx/mbox/", "series": [ { "id": 499508, "url": "http://patchwork.ozlabs.org/api/1.1/series/499508/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=499508", "date": "2026-04-10T20:56:11", "name": null, "version": 1, "mbox": "http://patchwork.ozlabs.org/series/499508/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2222217/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2222217/checks/", "tags": {}, "headers": { "Return-Path": "\n <linuxppc-dev+bounces-19616-incoming=patchwork.ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=GQ142PFW;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-19616-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)", "lists.ozlabs.org;\n arc=none smtp.remote-ip=\"2600:3c0a:e001:78e:0:1991:8:25\"", "lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org", "lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=GQ142PFW;\n\tdkim-atps=neutral", "lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org\n (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org;\n envelope-from=tglx@kernel.org; receiver=lists.ozlabs.org)" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1 raw public key)\n server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fspxb5KSVz1yGb\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 11 Apr 2026 06:56:19 +1000 (AEST)", "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fspxb4Rxpz2yjw;\n\tSat, 11 Apr 2026 06:56:19 +1000 (AEST)", "from sea.source.kernel.org (sea.source.kernel.org\n [IPv6:2600:3c0a:e001:78e:0:1991:8:25])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4fspxZ5hjqz2yhV\n\tfor <linuxppc-dev@lists.ozlabs.org>; Sat, 11 Apr 2026 06:56:18 +1000 (AEST)", "from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby sea.source.kernel.org (Postfix) with ESMTP id EABB3403ED;\n\tFri, 10 Apr 2026 20:56:16 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPSA id E2163C19421;\n\tFri, 10 Apr 2026 20:56:13 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775854579;\n\tcv=none;\n b=EBTsEFT1Tp5B1sfvACc3NA6xrsmrWOdRNDA8ihw3cPfW/yGcRfxKdcCiqaNFBxUEqKc9kzHA/R20X0bAXoE00uPG1maTAf0qFRniCMaWm+KFend2sUqqf4KRqXYuSfBOvGqzAn1RbNWXPYR1r/g9tRO+uBD6C6L/JDj9gBg8nBvytzvLr8si1gS4GiF0W1pFS3/58Zdu3YhkdopJdMYH37nHxN8VL1ouZKPo+aMKUjFTqd11ASG9ACezggrBM5QIvDj3ncdwdvVwTiuLmbZ7wtAlwJJykDFirbSWpvgv7hxV8uWItAy1ohh/JPjvkez2qFdTAjDT2kBCY1+xA8WjQA==", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1775854579; c=relaxed/relaxed;\n\tbh=C2X9IdtUnrT50yiykczKjUwFjhJemy6Dkqp8i9B0154=;\n\th=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:\n\t MIME-Version:Content-Type;\n b=D4/9dg50j1yNI8gsWbWLR3r3QUhDAuWE+uaUnsWRzOBW61wOzx7mKrne3STZB+cdGJ4ybJHr18qCklWCsFHJpDDkHZcQiBg7lJWalKb0MIa6Bpiy09qB666qhezHBfwYgejCVtnt9qd+z6uSjSSrGqEWMzomid5Vh9vHXrwob5krJjHUjNlXvZXgMqvINxbYCiSdwoDQzV/vmwuRrjDSqGsuJ7RYMN5RtI60Ows8/TOdiWwaA9v/YFdIJ6vv0GHMdA39DyJWoJRzVkWVAjWc7vkgKeHSaqKvbWstjChFBOOY2c0ksW7sPIpR9ENEOXlxJ+yI8jwW//Ma8ZDdZV76+w==", "ARC-Authentication-Results": "i=1; lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org;\n dkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=GQ142PFW; dkim-atps=neutral;\n spf=pass (client-ip=2600:3c0a:e001:78e:0:1991:8:25;\n helo=sea.source.kernel.org; envelope-from=tglx@kernel.org;\n receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1775854576;\n\tbh=Pl/TPuj3MEjAUAkiR6iNGQuG7vTK4etd1CQHextbc1Q=;\n\th=From:To:Cc:Subject:In-Reply-To:References:Date:From;\n\tb=GQ142PFWFm6CPGgxzIstxv+Opw0b8SXuQ9OyBP6RDGrB9wMYrgGJRlAIcXmjiMiJQ\n\t uvHLzYRX996/8mwPCxIT6HNprAxZjHfiZYVGdKL2zkx4tDdEJ1Qjhj23YsuYeVWZUk\n\t qB897HhG8G4RkSYw8g0MDIEY8t5mxlaTJQ0hQJRlVPLc72Bfpv47WYQcen6mmTC6UB\n\t IDYz08Lq5Ox+catFPgX2TnERo0NsyMmc6D+DEo5bfEi3Zb8CozxsaaIUnftUYBffz4\n\t eRJ2pErWPmB+XVojMvRq9gH2C+KSLENGTN6u78aH1Po3BWHW2gKcN/A+CamqsNtu9t\n\t mhyolj1ID3OUA==", "From": "Thomas Gleixner <tglx@kernel.org>", "To": "LKML <linux-kernel@vger.kernel.org>", "Cc": "Arnd Bergmann <arnd@arndb.de>, x86@kernel.org, Lu Baolu\n <baolu.lu@linux.intel.com>, iommu@lists.linux.dev, Michael Grzeschik\n <m.grzeschik@pengutronix.de>, netdev@vger.kernel.org,\n linux-wireless@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>,\n linux-crypto@vger.kernel.org, Vlastimil Babka <vbabka@kernel.org>,\n linux-mm@kvack.org, David Woodhouse <dwmw2@infradead.org>, Bernie Thompson\n <bernie@plugable.com>, linux-fbdev@vger.kernel.org, Theodore Tso\n <tytso@mit.edu>, linux-ext4@vger.kernel.org, Andrew Morton\n <akpm@linux-foundation.org>, Uladzislau Rezki <urezki@gmail.com>, Marco\n Elver <elver@google.com>, Dmitry Vyukov <dvyukov@google.com>,\n kasan-dev@googlegroups.com, Andrey Ryabinin <ryabinin.a.a@gmail.com>,\n Thomas Sailer <t.sailer@alumni.ethz.ch>, linux-hams@vger.kernel.org,\n \"Jason A. Donenfeld\" <Jason@zx2c4.com>, Richard Henderson\n <richard.henderson@linaro.org>, linux-alpha@vger.kernel.org, Russell King\n <linux@armlinux.org.uk>, linux-arm-kernel@lists.infradead.org, Catalin\n Marinas <catalin.marinas@arm.com>, Huacai Chen <chenhuacai@kernel.org>,\n loongarch@lists.linux.dev, Geert Uytterhoeven <geert@linux-m68k.org>,\n linux-m68k@lists.linux-m68k.org, Dinh Nguyen <dinguyen@kernel.org>, Jonas\n Bonn <jonas@southpole.se>, linux-openrisc@vger.kernel.org, Helge Deller\n <deller@gmx.de>, linux-parisc@vger.kernel.org, Michael Ellerman\n <mpe@ellerman.id.au>, linuxppc-dev@lists.ozlabs.org, Paul Walmsley\n <pjw@kernel.org>, linux-riscv@lists.infradead.org, Heiko Carstens\n <hca@linux.ibm.com>, linux-s390@vger.kernel.org, \"David S. Miller\"\n <davem@davemloft.net>, sparclinux@vger.kernel.org", "Subject": "[patch V1.1 11/38] misc: sgi-gru: Remove get_cycles() [ab]use", "In-Reply-To": "<20260410120318.320727701@kernel.org>", "References": "<20260410120044.031381086@kernel.org>\n <20260410120318.320727701@kernel.org>", "Date": "Fri, 10 Apr 2026 22:56:11 +0200", "Message-ID": "<87ik9yzg9g.ffs@tglx>", "X-Mailing-List": "linuxppc-dev@lists.ozlabs.org", "List-Id": "<linuxppc-dev.lists.ozlabs.org>", "List-Help": "<mailto:linuxppc-dev+help@lists.ozlabs.org>", "List-Owner": "<mailto:linuxppc-dev+owner@lists.ozlabs.org>", "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>", "List-Archive": "<https://lore.kernel.org/linuxppc-dev/>,\n <https://lists.ozlabs.org/pipermail/linuxppc-dev/>", "List-Subscribe": "<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>", "List-Unsubscribe": "<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>", "Precedence": "list", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Spam-Status": "No, score=-0.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED,\n\tDKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS\n\tautolearn=disabled version=4.0.1 OzLabs 8", "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org" }, "content": "Calculating a timeout from get_cycles() is a historical leftover without\nany functional requirement.\n\nUse ktime_get() instead.\n\nSigned-off-by: Thomas Gleixner <tglx@kernel.org>\n---\nV2: Fix typo\n---\n drivers/misc/sgi-gru/gruhandles.c | 20 ++++++++------------\n drivers/misc/sgi-gru/grukservices.c | 3 ++-\n drivers/misc/sgi-gru/grutlbpurge.c | 5 ++---\n 3 files changed, 12 insertions(+), 16 deletions(-)", "diff": "--- a/drivers/misc/sgi-gru/gruhandles.c\n+++ b/drivers/misc/sgi-gru/gruhandles.c\n@@ -6,26 +6,22 @@\n */\n \n #include <linux/kernel.h>\n+#include <linux/timekeeping.h>\n #include \"gru.h\"\n #include \"grulib.h\"\n #include \"grutables.h\"\n \n-/* 10 sec */\n #include <linux/sync_core.h>\n-#include <asm/tsc.h>\n-#define GRU_OPERATION_TIMEOUT\t((cycles_t) tsc_khz*10*1000)\n-#define CLKS2NSEC(c)\t\t((c) * 1000000 / tsc_khz)\n+\n+#define GRU_OPERATION_TIMEOUT_NSEC\t(((ktime_t)10 * NSEC_PER_SEC))\n \n /* Extract the status field from a kernel handle */\n #define GET_MSEG_HANDLE_STATUS(h)\t(((*(unsigned long *)(h)) >> 16) & 3)\n \n struct mcs_op_statistic mcs_op_statistics[mcsop_last];\n \n-static void update_mcs_stats(enum mcs_op op, unsigned long clks)\n+static void update_mcs_stats(enum mcs_op op, unsigned long nsec)\n {\n-\tunsigned long nsec;\n-\n-\tnsec = CLKS2NSEC(clks);\n \tatomic_long_inc(&mcs_op_statistics[op].count);\n \tatomic_long_add(nsec, &mcs_op_statistics[op].total);\n \tif (mcs_op_statistics[op].max < nsec)\n@@ -58,21 +54,21 @@ static void report_instruction_timeout(v\n \n static int wait_instruction_complete(void *h, enum mcs_op opc)\n {\n+\tktime_t start_time = ktime_get();\n \tint status;\n-\tunsigned long start_time = get_cycles();\n \n \twhile (1) {\n \t\tcpu_relax();\n \t\tstatus = GET_MSEG_HANDLE_STATUS(h);\n \t\tif (status != CCHSTATUS_ACTIVE)\n \t\t\tbreak;\n-\t\tif (GRU_OPERATION_TIMEOUT < (get_cycles() - start_time)) {\n+\t\tif (GRU_OPERATION_TIMEOUT_NSEC < (ktime_get() - start_time)) {\n \t\t\treport_instruction_timeout(h);\n-\t\t\tstart_time = get_cycles();\n+\t\t\tstart_time = ktime_get();\n \t\t}\n \t}\n \tif (gru_options & OPT_STATS)\n-\t\tupdate_mcs_stats(opc, get_cycles() - start_time);\n+\t\tupdate_mcs_stats(opc, (unsigned long)(ktime_get() - start_time));\n \treturn status;\n }\n \n--- a/drivers/misc/sgi-gru/grukservices.c\n+++ b/drivers/misc/sgi-gru/grukservices.c\n@@ -20,6 +20,7 @@\n #include <linux/uaccess.h>\n #include <linux/delay.h>\n #include <linux/export.h>\n+#include <linux/random.h>\n #include <asm/io_apic.h>\n #include \"gru.h\"\n #include \"grulib.h\"\n@@ -1106,7 +1107,7 @@ static int quicktest3(unsigned long arg)\n \tint ret = 0;\n \n \tmemset(buf2, 0, sizeof(buf2));\n-\tmemset(buf1, get_cycles() & 255, sizeof(buf1));\n+\tmemset(buf1, get_random_u32() & 255, sizeof(buf1));\n \tgru_copy_gpa(uv_gpa(buf2), uv_gpa(buf1), BUFSIZE);\n \tif (memcmp(buf1, buf2, BUFSIZE)) {\n \t\tprintk(KERN_DEBUG \"GRU:%d quicktest3 error\\n\", smp_processor_id());\n--- a/drivers/misc/sgi-gru/grutlbpurge.c\n+++ b/drivers/misc/sgi-gru/grutlbpurge.c\n@@ -22,13 +22,12 @@\n #include <linux/delay.h>\n #include <linux/timex.h>\n #include <linux/srcu.h>\n+#include <linux/random.h>\n #include <asm/processor.h>\n #include \"gru.h\"\n #include \"grutables.h\"\n #include <asm/uv/uv_hub.h>\n \n-#define gru_random()\tget_cycles()\n-\n /* ---------------------------------- TLB Invalidation functions --------\n * get_tgh_handle\n *\n@@ -49,7 +48,7 @@ static inline int get_off_blade_tgh(stru\n \tint n;\n \n \tn = GRU_NUM_TGH - gru->gs_tgh_first_remote;\n-\tn = gru_random() % n;\n+\tn = get_random_u32() % n;\n \tn += gru->gs_tgh_first_remote;\n \treturn n;\n }\n", "prefixes": [ "V1.1", "11/38" ] }