Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp437780rdb; Mon, 18 Sep 2023 22:53:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHi9QG6nw2nsq6jyLxWHy5xkEVJAyn6irnkezHovlWHYuK4Hf0jpoc4zposz6prK34gW97k X-Received: by 2002:a17:90b:3b42:b0:273:cb91:c74f with SMTP id ot2-20020a17090b3b4200b00273cb91c74fmr11072451pjb.8.1695102830985; Mon, 18 Sep 2023 22:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695102830; cv=none; d=google.com; s=arc-20160816; b=ArajFNnmIwbB9oUC/fA7GFvlEtfun1KlRJKjYqNcB/0h75XSfOpSMA6PJLX3F3sUIX PD4cfOclW1/X2zyFaFeZ3Hj1646AoxqowuSbmeGnjCXDaZg6glx50pUTkkf8MFDV59G1 ZGxVUaUPniPg8SHZoGqKuBPUUodoEMeaQNE2CyqR9dXUOXTR7QXuanmOzgdtFz1PUn+U OWMMdIpAvhrdYBnpwYrnN+sgUcjdQEg+N83QPilqKTNHRBQhSTguMmtDQ+EhZawR3Tj3 mgOPYjzXweBgkt0xUtz38acPUL7d8Gh2xXP635ue0ZR4Rypli6RNkcMc1xC+RbALgKoN CGSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id; bh=JOcQqm5T2l7FnqzIqZfGQiR6q/pI6ROhu9GBQdAWfvo=; fh=MpR0D+V7MsTW+vunquYXisVKI47CW+VZRZ7mJZI89Ug=; b=YAuFz/JSjG36O7V2CtCsycCiMEdPVGIzpVOozbbAJCTvTniHuFa+DTPvoIpNgBx0Qt qUUBcd6btV8HsFjPFhYJLDsGhZJWN7NvktBAd+ZRBPbRP8VgKGv/voayJqenWgmcUsSE 67gCAjHiN/X0ucQxy6IlyIOyQZYFTN3XUzhw1P07E7yy4f+MPgOQcBsHZ5jpoGtRCLk1 CBzy977bvh75XvuqniKPYfH63KK9cSQPO0RSOOap+MLDy3vuvShBnHdIadurCqn9NI1a 3hBQZoCUMbQ8PNlavbQMoztEl47JCAI6EUrTmi8/GYAKHX0jJjtLjQrCiXkZ4TG+PLL4 NRdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id c1-20020a17090ad90100b0026b49c1aa50si7373704pjv.111.2023.09.18.22.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 22:53:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 96DC580202D3; Mon, 18 Sep 2023 22:52:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231475AbjISFwy (ORCPT + 99 others); Tue, 19 Sep 2023 01:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230513AbjISFwv (ORCPT ); Tue, 19 Sep 2023 01:52:51 -0400 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A611114; Mon, 18 Sep 2023 22:52:46 -0700 (PDT) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-53136a13cd4so1628826a12.1; Mon, 18 Sep 2023 22:52:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695102764; x=1695707564; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JOcQqm5T2l7FnqzIqZfGQiR6q/pI6ROhu9GBQdAWfvo=; b=GtW8wyqTpFJLAoB8rt12TiETqgKCFy/cNTCngTVqcC/uGJw8ITNQLskPxf6c0ggfK+ c+ZmS+y7DKtIkbQ9UlS19IbX//DgbyZrq3FDVfZ9/C0PzhIin/wZNLQ22vNV0PL+1jNA PKkfEEaOvNj3jNL3T8s5D4bgwGguxt0YsxaDSQj+cgOSCZIHWCoWAbG42eVdT4hHItNw 1IplCgWfTCvN5wdtZv3BnlE7QEIfxVLYd/ohOtV57jYYBThlC2LQdyVOKcU8KZ/3ku74 XWWVXBWhyk64x12Cv0afjoTHe2MzRnB7FBBYmLVfz6KbS++wGWcfaH27Tq6Gh5R3kFOK q7IQ== X-Gm-Message-State: AOJu0Yw7xyAmTQaO/OF+pawGT52mvQ/ok3rbmXIroJq2Hp8SOANGg1Ne 4fXqQyEBYdbVYjaCvMDRe6s= X-Received: by 2002:a17:906:2921:b0:992:7295:61c9 with SMTP id v1-20020a170906292100b00992729561c9mr9021336ejd.69.1695102763492; Mon, 18 Sep 2023 22:52:43 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:59? ([2a0b:e7c0:0:107::aaaa:59]) by smtp.gmail.com with ESMTPSA id i23-20020a170906851700b00977eec7b7e8sm7326588ejx.68.2023.09.18.22.52.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Sep 2023 22:52:43 -0700 (PDT) Message-ID: Date: Tue, 19 Sep 2023 07:52:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] tty/sysrq: replace smp_processor_id() with get_cpu() Content-Language: en-US To: Greg Kroah-Hartman , Muhammad Usama Anjum Cc: Ingo Molnar , kernel@collabora.com, stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org References: <20230822102606.2821311-1-usama.anjum@collabora.com> <2023091835-quill-congress-b691@gregkh> From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcDwGs6tFVrAHvdHeIdI07s1iIx5R/ndcHwt4fvI8CL5PzPmn5J+h0WERR5rFprRh6axhOk rSD5CwQl19fm4AJCS6A9GJtOoiLpWn2/IbogPc71jQVrupZYYx51rAaHZ0D2KYK/uhfc6neJ i0WqPlbtIlIrpvWxckucNu6ZwXjFY0f3qIRg3Vqh5QxPkojGsq9tXVFVLEkSVz6FoqCHrUTx wr+aw6qqQVgvT/McQtsI0S66uIkQjzPUrgAEtWUv76rM4ekqL9stHyvTGw0Fjsualwb0Gwdx ReTZzMgheAyoy/umIOKrSEpWouVoBt5FFSZUyjuDdlPPYyPav+hpI6ggmCTld3u2hyiHji2H cDpcLM2LMhlHBipu80s9anNeZhCANDhbC5E+NZmuwgzHBcan8WC7xsPXPaiZSIm7TKaVoOcL 9tE5aN3jQmIlrT7ZUX52Ff/hSdx/JKDP3YMNtt4B0cH6ejIjtqTd+Ge8sSttsnNM0CQUkXps w98jwz+Lxw/bKMr3NSnnFpUZaxwji3BC9vYyxKMAwNelBCHEgS/OAa3EJoTfuYOK6wT6nadm YqYjwYbZE5V/SwzMbpWu7Jwlvuwyfo5mh7w5iMfnZE+vHFwp/wARAQABzSFK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WEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: <2023091835-quill-congress-b691@gregkh> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Mon, 18 Sep 2023 22:52:57 -0700 (PDT) On 18. 09. 23, 10:10, Greg Kroah-Hartman wrote: > On Tue, Aug 22, 2023 at 03:26:06PM +0500, Muhammad Usama Anjum wrote: >> The smp_processor_id() shouldn't be called from preemptible code. >> Instead use get_cpu() and put_cpu() which disables preemption in >> addition to getting the processor id. This fixes the following bug: >> >> [ 119.143590] sysrq: Show backtrace of all active CPUs >> [ 119.143902] BUG: using smp_processor_id() in preemptible [00000000] code: bash/873 >> [ 119.144586] caller is debug_smp_processor_id+0x20/0x30 >> [ 119.144827] CPU: 6 PID: 873 Comm: bash Not tainted 5.10.124-dirty #3 >> [ 119.144861] Hardware name: QEMU QEMU Virtual Machine, BIOS 2023.05-1 07/22/2023 >> [ 119.145053] Call trace: >> [ 119.145093] dump_backtrace+0x0/0x1a0 >> [ 119.145122] show_stack+0x18/0x70 >> [ 119.145141] dump_stack+0xc4/0x11c >> [ 119.145159] check_preemption_disabled+0x100/0x110 >> [ 119.145175] debug_smp_processor_id+0x20/0x30 >> [ 119.145195] sysrq_handle_showallcpus+0x20/0xc0 >> [ 119.145211] __handle_sysrq+0x8c/0x1a0 >> [ 119.145227] write_sysrq_trigger+0x94/0x12c >> [ 119.145247] proc_reg_write+0xa8/0xe4 >> [ 119.145266] vfs_write+0xec/0x280 >> [ 119.145282] ksys_write+0x6c/0x100 >> [ 119.145298] __arm64_sys_write+0x20/0x30 >> [ 119.145315] el0_svc_common.constprop.0+0x78/0x1e4 >> [ 119.145332] do_el0_svc+0x24/0x8c >> [ 119.145348] el0_svc+0x10/0x20 >> [ 119.145364] el0_sync_handler+0x134/0x140 >> [ 119.145381] el0_sync+0x180/0x1c0 >> >> Cc: stable@vger.kernel.org >> Fixes: 47cab6a722d4 ("debug lockups: Improve lockup detection, fix generic arch fallback") >> Signed-off-by: Muhammad Usama Anjum >> --- >> Changes since v2: >> - Add changelog and resend >> >> Changes since v1: >> - Add "Cc: stable@vger.kernel.org" tag >> --- >> drivers/tty/sysrq.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c >> index 23198e3f1461a..6b4a28bcf2f5f 100644 >> --- a/drivers/tty/sysrq.c >> +++ b/drivers/tty/sysrq.c >> @@ -262,13 +262,14 @@ static void sysrq_handle_showallcpus(u8 key) >> if (in_hardirq()) >> regs = get_irq_regs(); >> >> - pr_info("CPU%d:\n", smp_processor_id()); >> + pr_info("CPU%d:\n", get_cpu()); > > Why not call put_cpu() right here? > >> if (regs) >> show_regs(regs); >> else >> show_stack(NULL, NULL, KERN_INFO); >> >> schedule_work(&sysrq_showallcpus); >> + put_cpu(); > > Why wait so long here after you have scheduled work? Please drop the > cpu reference right away, you don't need to hold it for this length of > time, right? As I understand it, this way, schedule_work() will queue the work on the "gotten" (current) CPU. So sysrq_showregs_othercpus() will really dump other than the "gotten" cpu. If that is the case, it indeed should have been described in the commit log. regards, -- js suse labs