Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1531059

Re: [PATCH v3 20/30] perf clang jit: add PerfModule::doJIT to JIT perfhook functions

From "Wangnan (F)" <wangnan0@huawei.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3 20/30] perf clang jit: add PerfModule::doJIT to JIT perfhook functions
Date 2016-11-28 07:50 +0100
Message-ID <sInVg-724-11@gated-at.bofh.it> (permalink)
References <sHFhv-3nx-5@gated-at.bofh.it> <sHFrb-3qJ-1@gated-at.bofh.it> <sHOXv-14Z-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 2016/11/27 1:29, Alexei Starovoitov wrote:
> On Sat, Nov 26, 2016 at 07:03:44AM +0000, Wang Nan wrote:
>> PerfModule::doJIT JIT compile perfhook functions and saves result into
>> a map. Add a test case for it.
>>
>> At this stage perfhook functions can do no useful things because they
>> can't invoke external functions and can't return value. Following
>> commits are going to make improvment.
>>
>> Don't hook functions right after jitted because bpf_object is unavailable
>> during jitting but it should be the context of jitted functions.
>>
>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> ...
>> +	for (Function *F : JITFunctions) {
>> +		JITSymbol sym = CompileLayer.findSymbol(F->getName().str(), true);
>> +
>> +		/*
>> +		 * Type of F->getSection() is moving from
>> +		 * const char * to StringRef.
>> +		 * Convert it to std::string so we don't need
>> +		 * consider this API change.
>> +		 */
>> +		std::string sec(F->getSection());
>> +		std::string hook(&sec.c_str()[sizeof("perfhook:") - 1]);
>> +		perf_hook_func_t func = (perf_hook_func_t)(intptr_t)sym.getAddress();
>> +
>> +		if (JITResult[hook])
>> +			llvm::errs() << "Warning: multiple functions on hook "
>> +				     << hook << ", only one is used\n";
>> +		JITResult[hook] = func;
>> +	}
>> +	return 0;
>> +}
>> +
>>   class ClangOptions {
>>   	llvm::SmallString<PATH_MAX> FileName;
>>   	llvm::SmallString<64> KVerDef;
>> @@ -292,6 +359,10 @@ void perf_clang__init(void)
>>   	LLVMInitializeBPFTarget();
>>   	LLVMInitializeBPFTargetMC();
>>   	LLVMInitializeBPFAsmPrinter();
>> +
>> +	llvm::InitializeNativeTarget();
>> +	llvm::InitializeNativeTargetAsmPrinter();
>> +	llvm::InitializeNativeTargetAsmParser();
> Looks great. I bet a lot of people reading perf code
> won't be able to understand what you're doing here.
> Could you please add a design doc on how perf<->clang/llvm interaction
> is done.

I'll put a perf-clang.txt in tools/perf/Documentation.

Thank you.

> Acked-by: Alexei Starovoitov <ast@kernel.org>
>

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v3 20/30] perf clang jit: add PerfModule::doJIT to JIT perfhook functions Wang Nan <wangnan0@huawei.com> - 2016-11-26 08:20 +0100
  Re: [PATCH v3 20/30] perf clang jit: add PerfModule::doJIT to JIT  perfhook functions Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-11-26 18:30 +0100
    Re: [PATCH v3 20/30] perf clang jit: add PerfModule::doJIT to JIT  perfhook functions "Wangnan (F)" <wangnan0@huawei.com> - 2016-11-28 07:50 +0100

csiph-web