Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp689888ybh; Tue, 10 Mar 2020 06:31:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvVj2X+hBx8pUm2b4iWQ5kRWZrZQ1KC3vJN8DRKIQg3KkRAnHVmFBC9XiobxEFlgJR0A0v9 X-Received: by 2002:a54:4892:: with SMTP id r18mr1158926oic.81.1583847119380; Tue, 10 Mar 2020 06:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583847119; cv=none; d=google.com; s=arc-20160816; b=oRETVBOZQdPPVKj5Hp3WMZ4X7Ep1eLjXGg+SBdKzSNPCD1WsY9wUPFmD3pztY+s/C9 i/m4pzIYZvM7d2j5hRsApVV36wYee9avKc6exHIG4FmzgQiDRdlxD6ln1KDMhWbtD2E9 oUaxBzq0JxDV1oLEWd54+lihl73wjau1IDialRArJ06A/z5E+ZbU3CPxgC0727Mf4ImR 0wDflrEuPUTyk9TFV3CXRJ0eCfdONep0khPpAEx/MyBGkLmJ81Zilsm2N9mhaB8To8TQ ON3wfmuZQuWmvdNpO4UkjSMXiOuTjIVMTnniVtDCWQ9oSJ3AdPsDhigXEpyQ1R6ZBdyz x2aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=DSgnezMb2QdUmnV2xd4QebInlsJvoxs50foHZWkt7og=; b=o78H8eGIUMMSBM/4muE6TLWtED7/iyQm7f04IbHhlSB6D/5C5NAta4JwDCR7LIMFeO CxU3vHoxNzuy8WuvuQ47hdZrzHtsnAwjDWILaO+gRcGBQ3EM6yN3dO4xsZwBn0kCeITa kmuzcjidP8zcnzh3LRqHNY293q1cvuOMFXFqnYeJpWD+cDdKhtYoTxm1p6RDj1Iwdz9j U00gN62nAQ6cqtxDRMahb7t+6Swm5Bubkxg3p3vi8cctE+ANWzN1TWd6pucBgRfVr0Ev EE/kaUnQa5l/U44WTiFlzHASrA6ABNQP8yScWpQbmdG+OApDsvjjZZZ6EmwAXXoAe+V/ ezyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=tuj17UKP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d22si7892246ote.183.2020.03.10.06.31.47; Tue, 10 Mar 2020 06:31:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=tuj17UKP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729030AbgCJNbG (ORCPT + 99 others); Tue, 10 Mar 2020 09:31:06 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43458 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728271AbgCJNbE (ORCPT ); Tue, 10 Mar 2020 09:31:04 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02ADSOLi087988; Tue, 10 Mar 2020 13:30:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=DSgnezMb2QdUmnV2xd4QebInlsJvoxs50foHZWkt7og=; b=tuj17UKPx9J7QqbR7M85Pd8GQvPPx9R579HUFkMsQyiKOns+XVZHgUXbj6NOPXsEJMgh uV8AkXKeBlcYvMWjGzT32D+WiWmnnAFQ1OoqLi/Erz6sA5XZ0Ck4kRlib42hOSrfsE6z 1k3YyGgtftQ+N94i23tD/VxhouvKxA8PvFWAkukVf7ENghg3in7hK+ne+SrS1+xOTiyW PCuC23+mCjBSWC70vm8KSjg3TA+lyYgGUyZK+2fzEqIFDj4ebeAqweL40TLEIPFeJV+o lleR/SyzS226lyzV8fN9Q40ruee96oqhj+w+S43F+g1t7xEyhHE5uSvO30BsRaJzBdL3 6w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2yp9v60m2m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 13:30:24 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02ADRDDI178975; Tue, 10 Mar 2020 13:28:23 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2yp8qn7ax6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 13:28:23 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02ADSKog014517; Tue, 10 Mar 2020 13:28:20 GMT Received: from [192.168.8.5] (/213.41.92.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 06:28:20 -0700 Subject: Re: [patch part-II V2 09/13] x86/entry/common: Split hardirq tracing into lockdep and ftrace parts To: Thomas Gleixner , LKML Cc: x86@kernel.org, Steven Rostedt , Brian Gerst , Juergen Gross , Frederic Weisbecker References: <20200308222359.370649591@linutronix.de> <20200308222609.825111830@linutronix.de> From: Alexandre Chartre Organization: Oracle Corporation Message-ID: Date: Tue, 10 Mar 2020 14:28:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20200308222609.825111830@linutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 mlxscore=0 adultscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100090 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 adultscore=0 clxscore=1015 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100090 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/8/20 11:24 PM, Thomas Gleixner wrote: > trace_hardirqs_off() is in fact a tracepoint which can be utilized by BPF, > which is unsafe before calling enter_from_user_mode(), which in turn > invokes context tracking. trace_hardirqs_off() also invokes > lockdep_hardirqs_off() under the hood. > > OTOH lockdep needs to know about the interrupts disabled state before > enter_from_user_mode(). lockdep_hardirqs_off() is safe to call at this > point. > > Split it so lockdep knows about the state and invoke the tracepoint after > the context is set straight. > > Even if the functions attached to a tracepoint would all be safe to be > called in rcuidle having it split up is still giving a performance > advantage because rcu_read_lock_sched() is avoiding the whole dance of: > > scru_read_lock(); > rcu_irq_enter_irqson(); > ... > rcu_irq_exit_irqson(); > scru_read_unlock(); > > around the tracepoint function invocation just to have the C entry points > of syscalls call enter_from_user_mode() right after the above dance. > > Signed-off-by: Thomas Gleixner > --- > V2: New patch > --- > arch/x86/entry/common.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) Reviewed-by: Alexandre Chartre alex. > --- a/arch/x86/entry/common.c > +++ b/arch/x86/entry/common.c > @@ -60,10 +60,19 @@ static __always_inline void syscall_entr > { > /* > * Usermode is traced as interrupts enabled, but the syscall entry > - * mechanisms disable interrupts. Tell the tracer. > + * mechanisms disable interrupts. Tell lockdep before calling > + * enter_from_user_mode(). This is safe vs. RCU while the > + * tracepoint is not. > */ > - trace_hardirqs_off(); > + lockdep_hardirqs_on(CALLER_ADDR0); > + > enter_from_user_mode(); > + > + /* > + * Tell the tracer about the irq state as well before enabling > + * interrupts. > + */ > + __trace_hardirqs_off(); > local_irq_enable(); > } > >