Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp598961pxb; Wed, 27 Oct 2021 08:47:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycCgitHzjrMk7RfD6VAlcsMPS9AdLf5qAc9iv7xhVdc6VTcwTC6KSOFAohmvOvFODUM24y X-Received: by 2002:a17:906:3542:: with SMTP id s2mr39150620eja.379.1635349658579; Wed, 27 Oct 2021 08:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635349658; cv=none; d=google.com; s=arc-20160816; b=dpdfVStNjk9x8H3sSobSm5Ks2M2jG4EGWfQKArwf/XJsxWOz9Sm3iWD2q0OZveB7JW 5hKLpduOweSNdKZahl8IH+vB6UXT5s5flbvjUrPkpAs0Cvjh/JbQONQLSvmNyWW9tP6Y DAj5Qf5xgGuw3boCtmQWi+1KB3zQk5IY2dG/rfnSIPX7GEje9HmQiPkgERqqgbEyfvXr RUmUEv0i+ZM0Q/xHvtPQ3G0eV2hfmO1JKyp9xwpIE04WphqEuCRyZdSp9bkfhQweWOFk ITaBID/BLBnCmY9kq34OISbDW3L2EbtocyYYQJRQiqFapajI8BLGiDioL9LJMae3AqKb 1dcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:subject:from:to; bh=DaREKxhGA/f8qgMfhyAK0E/yBU1dylcWlTumhDkdLJM=; b=aMCpzZW2iW7k9NOAE4wC4oSsvHoU8F27/LYBGtl9VK3vfOirdY69xDT3SyuwTVb4hj pquvj0/UW3C0f6bDMT6Jl66aCm0yw71bstK3x1t+yZIvUAvUv2Ye/mOab/37SqpbuCXT MrX+3e9WcQxd2QfeVSv19cvNNQ7WqJckxX+eIyO6/xPLEpLwmLGe3G2BeEelQTqZe2Xs LwStqeYIkAnwkRGnz6ar6K7NcljC/VoKzpvegYRnimVFJbKpLApe4OSAKKqZSRnUbkIH I7M4QZZ77bHXkc3w8l2k72TGl9iVlwIP0tsMbUuDlc2rCXrpsPHG+9q51YsDea0vzMAc TWiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v12si256031edc.223.2021.10.27.08.47.14; Wed, 27 Oct 2021 08:47:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238264AbhJ0CfN (ORCPT + 99 others); Tue, 26 Oct 2021 22:35:13 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:56719 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232221AbhJ0CfM (ORCPT ); Tue, 26 Oct 2021 22:35:12 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R881e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=yun.wang@linux.alibaba.com;NM=1;PH=DS;RN=30;SR=0;TI=SMTPD_---0UtpxLVt_1635301961; Received: from testdeMacBook-Pro.local(mailfrom:yun.wang@linux.alibaba.com fp:SMTPD_---0UtpxLVt_1635301961) by smtp.aliyun-inc.com(127.0.0.1); Wed, 27 Oct 2021 10:32:43 +0800 To: Guo Ren , Steven Rostedt , Ingo Molnar , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Masami Hiramatsu , "Peter Zijlstra (Intel)" , Nicholas Piggin , Jisheng Zhang , linux-csky@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, live-patching@vger.kernel.org From: =?UTF-8?B?546L6LSH?= Subject: [PATCH v6 0/2] fix & prevent the missing preemption disabling Message-ID: Date: Wed, 27 Oct 2021 10:32:41 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The testing show that perf_ftrace_function_call() are using smp_processor_id() with preemption enabled, all the checking on CPU could be wrong after preemption. As Peter point out, the section between ftrace_test_recursion_trylock/unlock() pair require the preemption to be disabled as 'Documentation/trace/ftrace-uses.rst' explained, but currently the work is done outside of the helpers. And since the internal using of trace_test_and_set_recursion() and trace_clear_recursion() also require preemption to be disabled, we can just merge the logical together. Patch 1/2 will make sure preemption disabled when recursion lock succeed, patch 2/2 will do smp_processor_id() checking after trylock() to address the issue. v1: https://lore.kernel.org/all/8c7de46d-9869-aa5e-2bb9-5dbc2eda395e@linux.alibaba.com/ v2: https://lore.kernel.org/all/b1d7fe43-ce84-0ed7-32f7-ea1d12d0b716@linux.alibaba.com/ v3: https://lore.kernel.org/all/609b565a-ed6e-a1da-f025-166691b5d994@linux.alibaba.com/ V4: https://lore.kernel.org/all/32a36348-69ee-6464-390c-3a8d6e9d2b53@linux.alibaba.com/ V5: https://lore.kernel.org/all/3ca92dc9-ea04-ddc2-71cd-524bfa5a5721@linux.alibaba.com/ Michael Wang (2): ftrace: disable preemption when recursion locked ftrace: do CPU checking after preemption disabled arch/csky/kernel/probes/ftrace.c | 2 -- arch/parisc/kernel/ftrace.c | 2 -- arch/powerpc/kernel/kprobes-ftrace.c | 2 -- arch/riscv/kernel/probes/ftrace.c | 2 -- arch/x86/kernel/kprobes/ftrace.c | 2 -- include/linux/trace_recursion.h | 13 ++++++++++++- kernel/livepatch/patch.c | 13 +++++++------ kernel/trace/ftrace.c | 15 +++++---------- kernel/trace/trace_event_perf.c | 6 +++--- kernel/trace/trace_functions.c | 5 ----- 10 files changed, 27 insertions(+), 35 deletions(-) -- 1.8.3.1