Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3526491imm; Mon, 6 Aug 2018 06:24:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeHtUxOwH42tmp3zzjZxkFMWYnHjCtQ0lQevtGLezWUVVu9JKO2ZaHUvZvOWvd1WP4pb+Mo X-Received: by 2002:a63:6002:: with SMTP id u2-v6mr14532426pgb.433.1533561854194; Mon, 06 Aug 2018 06:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533561854; cv=none; d=google.com; s=arc-20160816; b=1DIgQLIIEtdffV82DCS0OJF3DmNLAl4CSKyGKdDe7me4Hj+7E88pYFpEkON8QEmgXj oiDnJ0C4ooSflHTMkBOFO+iweuuuw3J2WedOg2vKUJ5hE9IDZ2jQRPKoaW3n74ot+tnu QFcszeUGhRRTU+diQ1tN6UXcVhJ7m01kE2OCvyuVfNWQWdwCvbyEBglpWRHA9BQp+kxY Y7O4WYfaXQ9YHH2b+keSN7QeMtmRuc7J5u5sNfMxjkTrNVWTBANAnIYLHP0auZ56dsyF Hr592VD4U0i/9lUoevSIGstfUWUsdrIv/zMxDQnc1nePHpqWNKitsl5bnm0cTjDVJigP NVpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date :arc-authentication-results; bh=8yoZDGZe/LuH3tjZFJHHHGZG8ForGi82PyDUHMAknGA=; b=vCUcjnap3qO8DTd1WucWgnTLoFH8xMtMFd0EOWF4CVFxnxsYIa+945hHQOhrydNHum IbAG03N2wYQEldOa4a8AOAJPc2/b6ydUmFRsls2xzOYEhD+58/RFIDmit5U+xjTKbj/P yaqCIOs2mXoXND9YpjMMB1hxTg/BBhOxqo6LXgCB+6zaBLhYQjrr8uLxxNi7tr0O9l3d il5V7Ybjh9RLtV9tqTd9MVliZXgEdyy23aLa6hCEs5V0IZIp3os1sEoG2sChRC462b1F z176vzyXr0derI3ThvwY5QllvztL50z/RAMgnNO1DTGhBmg3ZQxooTI4ig4AJ32kznx2 T5zw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r13-v6si13834084pfi.147.2018.08.06.06.23.59; Mon, 06 Aug 2018 06:24:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732667AbeHFP1A (ORCPT + 99 others); Mon, 6 Aug 2018 11:27:00 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60408 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732659AbeHFP07 (ORCPT ); Mon, 6 Aug 2018 11:26:59 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w76DEAxe158095 for ; Mon, 6 Aug 2018 09:17:55 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2kppddhuv4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 06 Aug 2018 09:17:53 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 Aug 2018 14:17:52 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 6 Aug 2018 14:17:48 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w76DHlgX35979296 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 6 Aug 2018 13:17:47 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E8B442041; Mon, 6 Aug 2018 16:17:57 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B99944203F; Mon, 6 Aug 2018 16:17:56 +0100 (BST) Received: from localhost (unknown [9.152.212.144]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 6 Aug 2018 16:17:56 +0100 (BST) Date: Mon, 6 Aug 2018 15:17:46 +0200 From: Vasily Gorbik To: Masahiro Yamada , Michal Marek , Martin Schwidefsky , Heiko Carstens , Steven Rostedt , Ingo Molnar Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Andi Kleen Subject: [PATCH 3/4] trace: add -mcount-nop option support References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 x-cbid: 18080613-4275-0000-0000-000002A51DC1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18080613-4276-0000-0000-000037AD1EDF Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-06_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808060141 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org -mcount-nop gcc option generates the calls to the profiling functions as nops which allows to avoid patching mcount jump with NOP instructions initially. -mcount-nop gcc option will be activated if platform selects HAVE_NOP_MCOUNT and gcc actually supports it. In addition to that CC_USING_NOP_MCOUNT is defined and could be used by architectures to adapt ftrace patching behavior. Signed-off-by: Vasily Gorbik --- Makefile | 6 ++++++ kernel/trace/Kconfig | 5 +++++ kernel/trace/ftrace.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/Makefile b/Makefile index 621ebdbfbf89..281f4ededf3a 100644 --- a/Makefile +++ b/Makefile @@ -749,6 +749,12 @@ ifdef CONFIG_FTRACE_MCOUNT_RECORD CC_FLAGS_FTRACE += -mrecord-mcount export CC_USING_RECORD_MCOUNT := 1 endif + ifdef CONFIG_HAVE_NOP_MCOUNT + ifeq ($(call cc-option-yn, -mnop-mcount),y) + CC_FLAGS_FTRACE += -mnop-mcount + CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT + endif + endif endif ifdef CONFIG_HAVE_FENTRY ifeq ($(call cc-option-yn, -mfentry),y) diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index dcc0166d1997..855109214e3d 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -47,6 +47,11 @@ config HAVE_FENTRY help Arch supports the gcc options -pg with -mfentry +config HAVE_NOP_MCOUNT + bool + help + Arch supports the gcc options -pg with -mrecord-mcount and -nop-mcount + config HAVE_C_RECORDMCOUNT bool help diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index caf9cbf35816..310dfcb20d5b 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -2981,12 +2981,14 @@ static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs) p = &pg->records[i]; p->flags = rec_flags; +#ifndef CC_USING_NOP_MCOUNT /* * Do the initial record conversion from mcount jump * to the NOP instructions. */ if (!ftrace_code_disable(mod, p)) break; +#endif update_cnt++; } -- 2.18.0.13.gd42ae10