Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3313503imb; Tue, 5 Mar 2019 06:25:34 -0800 (PST) X-Google-Smtp-Source: APXvYqzxOhf/4u4p8P/ICHebHArKNsm/w+b2Op9b/FVVh0YMGlyvXi/YpYKIz8gd8aAXpET6FHgF X-Received: by 2002:a17:902:728d:: with SMTP id d13mr1516603pll.12.1551795934839; Tue, 05 Mar 2019 06:25:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551795934; cv=none; d=google.com; s=arc-20160816; b=RX6s8w8h9NWV/k2LzjLDfuxUR73DlRiw/izcVv6sr3NQTQB5SVsIpnPv9Q2qItAm67 r4YJ4bDoCkASXToHFPefZbjp5oEimJcUo+7WjfwPVyIFLoD0VJ8vR/2bkfL5hN1IWinp kJv9TSmg+iGpYtazTQEvdA6kHLh7oGAmR4emLoUCLv3oT9y0C2Oj0M6U3ZE5ORuxROFv gT0DktFgVvp4pbVfIEc7+lnAYQQ9tvPqZkQOxNswNgoCbvDvsfsEXoGAl9fgwYgqnbWl r6803q0RhwJCoQmqBikc2MGlDMEYt0iYvoazwlLvRNNLOyp+xv2FstPXqMwgr2svNcZA T//A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:date:from:references:cc :to:subject; bh=4Z2cPStO9mntkx+UjZUAtuNJEG6Ph6G2xNp+Ol3f97c=; b=UxkzmKebNB7ffGNySaX978SjoxghBLkA3Hw9Fr5h77PUsR/EvgEuHdYoc4Tne6AtZN 5L89RQzkaQHB/JSMkkP3LPY7uhTuH3JhiqgeGgeWCmlLbclZwOsH0IcbLLkEk0fk3GkV P26i8vZF4WJbtl8duexvH6A0fuqKOgZ+oq0/ASqNLMoczPhzHMu9XQDfrKjAJkhmqm9+ wTosdysZ2p/jPDkxjo7IGg8/bbzeENcnWrglT5IuaeJsHXGGJZPgMdq606L20FB8hOEi 18Rtf7mctud0H94OfdZag6EoNP+1uL2aB22eJ3kYcS3GVmLOfrdHG1sCN3CMNP7tumUM qCfw== 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 f77si8380261pfa.175.2019.03.05.06.25.19; Tue, 05 Mar 2019 06:25:34 -0800 (PST) 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 S1727978AbfCEN6F (ORCPT + 99 others); Tue, 5 Mar 2019 08:58:05 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59134 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727751AbfCEN6E (ORCPT ); Tue, 5 Mar 2019 08:58:04 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x25DnSVq137405 for ; Tue, 5 Mar 2019 08:58:03 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2r1sc23gqg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 05 Mar 2019 08:58:03 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Mar 2019 13:58:01 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 5 Mar 2019 13:57:56 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x25Dvt6m47644682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 Mar 2019 13:57:55 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7B78A4068; Tue, 5 Mar 2019 13:57:55 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 42BF0A405F; Tue, 5 Mar 2019 13:57:55 +0000 (GMT) Received: from [9.152.212.90] (unknown [9.152.212.90]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 5 Mar 2019 13:57:55 +0000 (GMT) Subject: Re: [PATCH v3 2/3] gcov: Clang support To: Tri Vo Cc: ghackmann@android.com, ndesaulniers@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, yamada.masahiro@socionext.com, Trilok Soni , Prasad Sodagudi , Daniel Mentz , Petri Gynther References: <20190122233749.42220-1-trong@android.com> <20190122233749.42220-3-trong@android.com> From: Peter Oberparleiter Date: Tue, 5 Mar 2019 14:57:55 +0100 MIME-Version: 1.0 In-Reply-To: <20190122233749.42220-3-trong@android.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 19030513-0028-0000-0000-000003503060 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19030513-0029-0000-0000-0000240E9A4E Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-05_08:,, 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-1810050000 definitions=main-1903050093 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23.01.2019 00:37, Tri Vo wrote: > From: Greg Hackmann > > LLVM uses profiling data that's deliberately similar to GCC, but has a very > different way of exporting that data. LLVM calls llvm_gcov_init() once per > module, and provides a couple of callbacks that we can use to ask for more > data. > > We care about the "writeout" callback, which in turn calls back into > compiler-rt/this module to dump all the gathered coverage data to disk: > > llvm_gcda_start_file() > llvm_gcda_emit_function() > llvm_gcda_emit_arcs() > llvm_gcda_emit_function() > llvm_gcda_emit_arcs() > [... repeats for each function ...] > llvm_gcda_summary_info() > llvm_gcda_end_file() > > This design is much more stateless and unstructured than gcc's, and is > intended to run at process exit. This forces us to keep some local state > about which module we're dealing with at the moment. On the other hand, it > also means we don't depend as much on how LLVM represents profiling data > internally. > > See LLVM's lib/Transforms/Instrumentation/GCOVProfiling.cpp for more > details on how this works, particularly GCOVProfiler::emitProfileArcs(), > GCOVProfiler::insertCounterWriteout(), and GCOVProfiler::insertFlush(). > > Co-authored-by: Nick Desaulniers > Co-authored-by: Tri Vo > 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 > Tested-by: Daniel Mentz > Tested-by: Petri Gynther > --- > kernel/gcov/Kconfig | 3 +- > kernel/gcov/Makefile | 1 + > kernel/gcov/clang.c | 555 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 558 insertions(+), 1 deletion(-) > create mode 100644 kernel/gcov/clang.c > [...] > diff --git a/kernel/gcov/clang.c b/kernel/gcov/clang.c > new file mode 100644 > index 000000000000..f9acdee3d578 > --- /dev/null > +++ b/kernel/gcov/clang.c > @@ -0,0 +1,555 @@ [...] > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include "gcov.h" > + > +#define GCOV_TAG_FUNCTION_LENGTH 3 This define seems to be unused and should be removed. [...] > +/** > + * gcov_info_unlink - unlink/remove profiling data set from the list > + * @prev: previous profiling data set > + * @info: profiling data set > + */ > +void gcov_info_unlink(struct gcov_info *prev, struct gcov_info *info) > +{ > + if (info) > + list_del(&info->head); The if-clause can be removed since @info is always non-NULL. [...] > +static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn) > +{ > + size_t cv_size; /* counter values size */ > + This empty line should be removed. [...] Rest looks good! With these minor changes applied: Reviewed-by: Peter Oberparleiter -- Peter Oberparleiter Linux on Z Development - IBM Germany