Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4648420yba; Wed, 17 Apr 2019 16:24:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5suxx0NpuEVwKxeWHSpr6T8wgOJ7n8eapvF/cKzVNhXojPZGpC5GGXPEbOJr96pKuKXj8 X-Received: by 2002:a17:902:ab91:: with SMTP id f17mr27800273plr.151.1555543458333; Wed, 17 Apr 2019 16:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555543458; cv=none; d=google.com; s=arc-20160816; b=puFeXNYhA2F5Fmk7PXBnkl9kVFeh960BoY2QUY1MMj7auyjTBQN5PRnQguzT+tj4S+ a9XSGA2p1cTKeb1a6bNKxNkFkj9pPL7sbzd1jEePC+Zjh1i3d6YZQeR8fJYSWlYSp8kE v8fKmzoupxMscHwk3aUuffzl+9AyGJWltnDXwGc1Ftk72MEq2LEkcxxo+vqC9k6y98QT AAC9yEr1mFxnfz0vcH4C2nqgkI2CDvpqa7vQw0N7urQGaWP/1ApuQjiHkcakDvXCrpnj hXGhCVhCkOaGyBN4chhGULuYjeOS2ggfxhqT1TrALawXtfSYUmrsYB6Khl9X19BdK7GK TQyg== 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:subject:cc:to:from:date; bh=52dMrXYTsmCHRTxCFU8BM1Z72iwt573EmWJHUBdzcnQ=; b=BCdjK6zzfxq2hJ+YOoF49jxFp9jXi8by/4fphO0kle0Cn5hGq/qQz0kDYt6u/xeMx5 y5/kB9WNurGZa7HKaednGA1YYGTASWV1u+3a5q0YkPyNXJta1Nyx5sM6xHw7rsq8Jysh eEERRtKi/LR94mbXo6W0CGjswTXKimhy5UiJ/J1P5PnoSOzrrgCc35PT3pzgUbcpTAFN Ok82ez+Z7gyJefDdwry+ds2a7jDzotB7mxe63K3KP/kyd5GhgLfGLevCuCfh/56vEm8E G3TUztt4wLhAHxrgygiy+RjvKoDdRqWPAjmuxfiEHyxZ5+VDWPu5+NXKITlit0EHbfg3 M+Bw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si353442pla.230.2019.04.17.16.24.02; Wed, 17 Apr 2019 16:24:18 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387732AbfDQXVm (ORCPT + 99 others); Wed, 17 Apr 2019 19:21:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34752 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387611AbfDQXVm (ORCPT ); Wed, 17 Apr 2019 19:21:42 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 01E45C37; Wed, 17 Apr 2019 23:21:40 +0000 (UTC) Date: Wed, 17 Apr 2019 16:21:39 -0700 From: Andrew Morton To: Tri Vo Cc: ghackmann@android.com, ndesaulniers@google.com, linux-kernel@vger.kernel.org, oberpar@linux.ibm.com, Trilok Soni , Prasad Sodagudi , Daniel Mentz , Petri Gynther Subject: Re: [PATCH v5] gcov: Clang support Message-Id: <20190417162139.2ca3ba78eab414b2fa854a07@linux-foundation.org> In-Reply-To: <20190417225328.208129-1-trong@android.com> References: <20190417225328.208129-1-trong@android.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 17 Apr 2019 15:53:28 -0700 Tri Vo wrote: > 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(). checkpatch speaketh truth. Also, I'll change those Co-authored-by's to the documented Co-developed-by. From: Andrew Morton Subject: gcov-clang-support-checkpatch-fixes WARNING: Non-standard signature: Co-authored-by: #31: Co-authored-by: Nick Desaulniers WARNING: Non-standard signature: Co-authored-by: #32: Co-authored-by: Tri Vo WARNING: Possible unnecessary 'out of memory' message #158: FILE: kernel/gcov/clang.c:90: + if (!info) { + pr_warn_ratelimited("failed to allocate gcov info\n"); WARNING: Possible unnecessary 'out of memory' message #193: FILE: kernel/gcov/clang.c:125: + if (!info) { + pr_warn_ratelimited("failed to allocate gcov function info for %s\n", WARNING: line over 80 characters #546: FILE: kernel/gcov/clang.c:478: + pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); total: 0 errors, 5 warnings, 663 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. ./patches/gcov-clang-support.patch has style problems, please review. NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. Please run checkpatch prior to sending patches Cc: Daniel Mentz Cc: Greg Hackmann Cc: Nick Desaulniers Cc: Peter Oberparleiter Cc: Petri Gynther Cc: Prasad Sodagudi Cc: Trilok Soni Cc: Tri Vo Signed-off-by: Andrew Morton --- kernel/gcov/clang.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) --- a/kernel/gcov/clang.c~gcov-clang-support-checkpatch-fixes +++ a/kernel/gcov/clang.c @@ -86,10 +86,8 @@ void llvm_gcov_init(llvm_gcov_callback w { struct gcov_info *info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) { - pr_warn_ratelimited("failed to allocate gcov info\n"); + if (!info) return; - } INIT_LIST_HEAD(&info->head); INIT_LIST_HEAD(&info->functions); @@ -121,11 +119,8 @@ void llvm_gcda_emit_function(u32 ident, { struct gcov_fn_info *info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) { - pr_warn_ratelimited("failed to allocate gcov function info for %s\n", - function_name ?: "UNKNOWN"); + if (!info) return; - } INIT_LIST_HEAD(&info->head); info->ident = ident; _