Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752824AbcKZRcl (ORCPT ); Sat, 26 Nov 2016 12:32:41 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35939 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752245AbcKZRce (ORCPT ); Sat, 26 Nov 2016 12:32:34 -0500 Date: Sat, 26 Nov 2016 09:32:29 -0800 From: Alexei Starovoitov To: Wang Nan Cc: acme@redhat.com, ast@fb.com, lizefan@huawei.com, hekuang@huawei.com, linux-kernel@vger.kernel.org, pi3orama@163.com, joe@ovn.org, Jiri Olsa Subject: Re: [PATCH v3 19/30] perf clang jit: Insignt BPF and JIT functions in a Module Message-ID: <20161126173228.GH83987@ast-mbp.thefacebook.com> References: <20161126070354.141764-1-wangnan0@huawei.com> <20161126070354.141764-20-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161126070354.141764-20-wangnan0@huawei.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1102 Lines: 33 On Sat, Nov 26, 2016 at 07:03:43AM +0000, Wang Nan wrote: > Identify BPF functions, JIT functions and maps during init. Functions in > section starting with "perfhook:" are JIT functions. They will be JIT > compiled and hooked at perfhooks. > > During init of PerfModule, mark JIT functions as AvailableExternallyLinkage. > LLVM skips functions with linkage like this so they won't be compiled > into BPF objects. > > Signed-off-by: Wang Nan ... > +void PerfModule::prepareBPF(void) > +{ > + for (llvm::Function *F : JITFunctions) > + F->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage); > + for (llvm::Function *F : BPFFunctions) > + F->setLinkage(llvm::GlobalValue::ExternalLinkage); > + > +} > + > +void PerfModule::prepareJIT(void) > +{ > + for (llvm::Function *F : BPFFunctions) > + F->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage); > + for (llvm::Function *F : JITFunctions) > + F->setLinkage(llvm::GlobalValue::ExternalLinkage); > + > +} Nice trick. Please document it in the perf+llvm design doc. Acked-by: Alexei Starovoitov