From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexei Starovoitov Subject: Re: [RFC PATCH bpf-next 2/6] bpf: add bpf_get_stack helper Date: Sun, 8 Apr 2018 22:02:38 -0700 Message-ID: <49c15114-c518-b591-470a-b4073a675588@fb.com> References: <20180406214846.916265-1-yhs@fb.com> <20180406214846.916265-3-yhs@fb.com> <625de1bb-7cb2-5f9e-01c3-a863cd27b0e6@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Cc: To: Yonghong Song , , Return-path: Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:41208 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750895AbeDIFDD (ORCPT ); Mon, 9 Apr 2018 01:03:03 -0400 In-Reply-To: <625de1bb-7cb2-5f9e-01c3-a863cd27b0e6@fb.com> Sender: netdev-owner@vger.kernel.org List-ID: On 4/8/18 9:53 PM, Yonghong Song wrote: >>> @@ -1004,7 +1007,8 @@ static void __bpf_prog_put(struct bpf_prog >>> *prog, bool do_idr_lock) >>> bpf_prog_kallsyms_del(prog->aux->func[i]); >>> bpf_prog_kallsyms_del(prog); >>> >>> - call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); >>> + synchronize_rcu(); >>> + __bpf_prog_put_rcu(&prog->aux->rcu); >> >> there should have been lockdep splat. >> We cannot call synchronize_rcu here, since we cannot sleep >> in some cases. > > Let me double check this. The following is the reason > why I am using synchronize_rcu(). > > With call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu) and > _bpf_prog_put_rcu calls put_callchain_buffers() which > calls mutex_lock(), the runtime with CONFIG_DEBUG_ATOMIC_SLEEP=y > will complains since potential sleep inside the call_rcu is not > allowed. I see. Indeed. We cannot call put_callchain_buffers() from rcu callback, but doing synchronize_rcu() here is also not possible. How about moving put_callchain into bpf_prog_free_deferred() ?