Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp46722img; Sun, 17 Mar 2019 19:55:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+PtMaON0WXOB+UwPYJm3fu9LGD3hXJDTC10TS7X6RTKfD4owB3XKb8A5zkQ4aX1qmS9T/ X-Received: by 2002:a63:6a48:: with SMTP id f69mr15328221pgc.7.1552877746619; Sun, 17 Mar 2019 19:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552877746; cv=none; d=google.com; s=arc-20160816; b=yeImAiqJL9RNFsc5rNs6fDIAQOSOyL9N3s2mCdcc+VM7CEtsv7f5DV1L1gkyQFvmjJ dJRaJrjU8BHl4Od3o3W7TLu/jPS6AUgVcLGSxLfsOgTb57ZAVxKI/aCYIh+C73tz468E cb0BxLrxehJL+u0AwE/ih0IusJT0SgL/FJY2plCSJKq9Dewm62glTGpZHktFKoEAdutZ 7ChmVv3kv56wtvWSU1Fw3h4AysCqhNTVVJ+NWGyRRqsKpKJKTeaLKp0wKr2d+TM9E22B 3+L0H9Q3Xfvb2iNOubX5b0PLJA1bEO4N1pw0dfEYWb6tFa5fS8u5ROF9Yt9z823HfUeb 0D/A== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9LO9kgJmE8Q1XXRyG10ntfuNrII39zZgFWKhScJB1QU=; b=HtXW0n9u4B/85iVI+odGcUFBoICTfo77s0irwWoX9zmOQEEPZFamnRWoMb6VuzG3KO w/4yPKMUPcW5fER9qwwytw7uRqbCaOOmPAZMiy+BXGWatd9W5O79vOspSaD0FWPRbDw0 wJNP1HXYLEcqKKGQWHLzLAaXyNi6RClBy3P7agH/CAlwwIyzAaftS01ixf5PnmZzdciq PEG0mSRj7LsccudCxH6vh2EJd1/scNqGDHW8ENcaaEj31pw2Q5KJzO7Md4SDzCSUf/GQ jGKsJlrox62sgI2KGzCSV7kEy5JvGgzb5NY17hDc0uHgivDm5uoxQRCjhjFYLlXpyVY7 lmAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b="upKR3T/8"; 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=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si8777951plb.0.2019.03.17.19.55.31; Sun, 17 Mar 2019 19:55:46 -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=@android.com header.s=20161025 header.b="upKR3T/8"; 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=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbfCRCyt (ORCPT + 99 others); Sun, 17 Mar 2019 22:54:49 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:36650 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727425AbfCRCyt (ORCPT ); Sun, 17 Mar 2019 22:54:49 -0400 Received: by mail-pf1-f196.google.com with SMTP id p10so3424935pff.3 for ; Sun, 17 Mar 2019 19:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9LO9kgJmE8Q1XXRyG10ntfuNrII39zZgFWKhScJB1QU=; b=upKR3T/8mg2ohnzHTGSjZ5JRIsFuf3siD+CSlm5ZXKir89/TFMe8smtmtT63ni2EI1 jdY/zPW9VLYofXIQv1ns0BWafdWJonnIZHOMRNd1YNiMrReUoR8LiJXGjJgg/5pRg/1r EdJ8HFOZhdG7lvS/+MwdQU5v9YZ+x0ESxV9ekq/g46+4GsU7q4YxdEq4JR/y69f70aDA Gz2DsBGlvhD47dkLb9yPeAHuE0rxDr9hEllzx9xvHeADrV9q8trJg0JG1oLLmNFDEDv0 3E7kf4kXF6iZGibu9/QZQfDTdAwaSG/vuDWKqZZWS7tcDR74Vgu5tGd+k4Nc1OtKbNyE Ca2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9LO9kgJmE8Q1XXRyG10ntfuNrII39zZgFWKhScJB1QU=; b=lp+zrEEZCxeQOmfjATIsYIpKSGeSR4NmvuHMdOmQizKDSo+t+EtQDWRAn22ihEN8f5 wPArHRar7OBHBu5Eso6RhEK7/VYjv1bZWN7i6RuBzLIXPNAnVCeWy+aw0WQeYJ+mxDad Hjw/WkeMOtuZZ1JjJhD+SXnRHCT6TmCikb+gNDnNFeCIZMWAHJkfJelO9DsP/isrq1hJ L+fYlNPZmdSvkpfXMwkAugKLT+TqE+hXdu9vzz4kvjN4DlIiBcl/9SyvYWRoxToL0s13 TsWEB9W55w3s3KOBpT+Cb0v4Beypd4RfAa9DUIo8cJRVvuVnXcvWctdp9CTooUC1mY5K KNYg== X-Gm-Message-State: APjAAAX5pvbAI3S86kXIfzsxj+CbvT1ooI5XrpNJCuKk/BOziELrDt7S JVsnbjEOTY63uQZFoueVTiPlUA== X-Received: by 2002:a63:c00a:: with SMTP id h10mr14416081pgg.272.1552877688714; Sun, 17 Mar 2019 19:54:48 -0700 (PDT) Received: from trong0.mtv.corp.google.com ([2620:0:1000:1601:c43f:8c1b:f6ef:3dce]) by smtp.gmail.com with ESMTPSA id i126sm13672955pfc.101.2019.03.17.19.54.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 19:54:48 -0700 (PDT) From: Tri Vo To: oberpar@linux.ibm.com Cc: ghackmann@android.com, ndesaulniers@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, yamada.masahiro@socionext.com, akpm@linux-foundation.org, Tri Vo , Trilok Soni , Prasad Sodagudi Subject: [PATCH v4 1/3] gcov: Clang: move common GCC code into gcc_base.c Date: Sun, 17 Mar 2019 19:54:09 -0700 Message-Id: <20190318025411.98014-2-trong@android.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog In-Reply-To: <20190318025411.98014-1-trong@android.com> References: <20190318025411.98014-1-trong@android.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Hackmann base.c contains a few callbacks specific to GCC's gcov implementation. Move these into their own module in preparation for Clang support. Signed-off-by: Greg Hackmann Signed-off-by: Nick Desaulniers Signed-off-by: Tri Vo Tested-by: Trilok Soni Tested-by: Prasad Sodagudi Tested-by: Tri Vo Reviewed-by: Peter Oberparleiter --- kernel/gcov/Makefile | 4 +- kernel/gcov/base.c | 84 +---------------------------------------- kernel/gcov/gcc_base.c | 86 ++++++++++++++++++++++++++++++++++++++++++ kernel/gcov/gcov.h | 3 ++ 4 files changed, 93 insertions(+), 84 deletions(-) create mode 100644 kernel/gcov/gcc_base.c diff --git a/kernel/gcov/Makefile b/kernel/gcov/Makefile index ff06d64df397..45431ed679d1 100644 --- a/kernel/gcov/Makefile +++ b/kernel/gcov/Makefile @@ -2,5 +2,5 @@ ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"' obj-y := base.o fs.o -obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_3_4.o -obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_4_7.o +obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_base.o gcc_3_4.o +obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_base.o gcc_4_7.o diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c index 9c7c8d5c18f2..799d42072727 100644 --- a/kernel/gcov/base.c +++ b/kernel/gcov/base.c @@ -22,88 +22,8 @@ #include #include "gcov.h" -static int gcov_events_enabled; -static DEFINE_MUTEX(gcov_lock); - -/* - * __gcov_init is called by gcc-generated constructor code for each object - * file compiled with -fprofile-arcs. - */ -void __gcov_init(struct gcov_info *info) -{ - static unsigned int gcov_version; - - mutex_lock(&gcov_lock); - if (gcov_version == 0) { - gcov_version = gcov_info_version(info); - /* - * Printing gcc's version magic may prove useful for debugging - * incompatibility reports. - */ - pr_info("version magic: 0x%x\n", gcov_version); - } - /* - * Add new profiling data structure to list and inform event - * listener. - */ - gcov_info_link(info); - if (gcov_events_enabled) - gcov_event(GCOV_ADD, info); - mutex_unlock(&gcov_lock); -} -EXPORT_SYMBOL(__gcov_init); - -/* - * These functions may be referenced by gcc-generated profiling code but serve - * no function for kernel profiling. - */ -void __gcov_flush(void) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_flush); - -void __gcov_merge_add(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_add); - -void __gcov_merge_single(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_single); - -void __gcov_merge_delta(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_delta); - -void __gcov_merge_ior(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_ior); - -void __gcov_merge_time_profile(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_time_profile); - -void __gcov_merge_icall_topn(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_icall_topn); - -void __gcov_exit(void) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_exit); +int gcov_events_enabled; +DEFINE_MUTEX(gcov_lock); /** * gcov_enable_events - enable event reporting through gcov_event() diff --git a/kernel/gcov/gcc_base.c b/kernel/gcov/gcc_base.c new file mode 100644 index 000000000000..3cf736b9f880 --- /dev/null +++ b/kernel/gcov/gcc_base.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include "gcov.h" + +/* + * __gcov_init is called by gcc-generated constructor code for each object + * file compiled with -fprofile-arcs. + */ +void __gcov_init(struct gcov_info *info) +{ + static unsigned int gcov_version; + + mutex_lock(&gcov_lock); + if (gcov_version == 0) { + gcov_version = gcov_info_version(info); + /* + * Printing gcc's version magic may prove useful for debugging + * incompatibility reports. + */ + pr_info("version magic: 0x%x\n", gcov_version); + } + /* + * Add new profiling data structure to list and inform event + * listener. + */ + gcov_info_link(info); + if (gcov_events_enabled) + gcov_event(GCOV_ADD, info); + mutex_unlock(&gcov_lock); +} +EXPORT_SYMBOL(__gcov_init); + +/* + * These functions may be referenced by gcc-generated profiling code but serve + * no function for kernel profiling. + */ +void __gcov_flush(void) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_flush); + +void __gcov_merge_add(gcov_type *counters, unsigned int n_counters) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_merge_add); + +void __gcov_merge_single(gcov_type *counters, unsigned int n_counters) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_merge_single); + +void __gcov_merge_delta(gcov_type *counters, unsigned int n_counters) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_merge_delta); + +void __gcov_merge_ior(gcov_type *counters, unsigned int n_counters) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_merge_ior); + +void __gcov_merge_time_profile(gcov_type *counters, unsigned int n_counters) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_merge_time_profile); + +void __gcov_merge_icall_topn(gcov_type *counters, unsigned int n_counters) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_merge_icall_topn); + +void __gcov_exit(void) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_exit); diff --git a/kernel/gcov/gcov.h b/kernel/gcov/gcov.h index de118ad4a024..0ecf1d664ec3 100644 --- a/kernel/gcov/gcov.h +++ b/kernel/gcov/gcov.h @@ -83,4 +83,7 @@ struct gcov_link { }; extern const struct gcov_link gcov_link[]; +extern int gcov_events_enabled; +extern struct mutex gcov_lock; + #endif /* GCOV_H */ -- 2.21.0.225.g810b269d1ac-goog