Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3147576pxk; Mon, 7 Sep 2020 04:46:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7ZnFGwM4ffP+rFMn46db2toaJyER4xnVHak5ejvCk0GKTi8lNof/bhXhg15Jzio1aaZxS X-Received: by 2002:a17:906:e88:: with SMTP id p8mr16389026ejf.134.1599479164022; Mon, 07 Sep 2020 04:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599479164; cv=none; d=google.com; s=arc-20160816; b=IHBPUl+2NFx6byoiXq5Sq97rMgC41l6CvhjPMs5fzIkZLCQST8Tiwq071JyC5QRbn3 /XRTphE25PWHfj35uXhgLwYznOaZwo6Tv5e6nzrw/v8CS9nyK98PVX3AnwQpuXaptcvI G08h6n86tarrolu3+rTIuE30IkWWD7Vf9iqKHhd5YwakszN+lfyWBNizBxZFhxvpm1Jq ygdyiffdNlsdKH7XxRcT4c4zLeLmEdnngijvNroc3ko09lzhz+fjCNHtNRuOjlyrOUTl 8HjeDavfHgyBENfUYhYaGqFWdjRkmXRQCD9kH2c+DYsz9L8YSbyNljrK3bE3FCvfXJN8 b8GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Up+NtoEoKF1B3IFUbGlV4iwCjaDtp0Abje/+V+Ja+dY=; b=iVdn3mQUUUVbOIn5soPs2tDu1Sl2NIr2cfajjGe9yrz/3SMIybNDqQRqij+5DfoBKR xf09Y1mrnDryREAIFBDz6kuonS5ZlljfYOxa5NKdZZ9tULuZYEoK++HOtUpvIvhaFJ7g XZelCAnkddX8j7DNfCUvjZEbhW+D/oU7WXLoOLewTysCoZvZGDaCp5VTsz15UWiN4UVw 1wJ1WTacxHTApD8Ok99e2tOZN1wgrzJNuanutpC1fTGA7erEUuhIEm64BYGTjsC92J5R 1mcHL1o76xWwSF0jUHixAls02q4cx3JuH0aeGquZKwEgE/0dlTowR1/qmBE6cHpgNCHs eoYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gidG8iko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u15si9331332ejx.239.2020.09.07.04.45.41; Mon, 07 Sep 2020 04:46:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gidG8iko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729019AbgIGLoU (ORCPT + 99 others); Mon, 7 Sep 2020 07:44:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30815 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729043AbgIGLnL (ORCPT ); Mon, 7 Sep 2020 07:43:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599478990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Up+NtoEoKF1B3IFUbGlV4iwCjaDtp0Abje/+V+Ja+dY=; b=gidG8iko2bR8798ai1rgrwdV/XPFt9G0nsZCxcMRq3BOjgv6nLhi+V+aI7GFWw4q+CW0c1 MWLeSn1ZxmWKjzMMrB0mwHM4Yc139rE4nNqFbXSZysch81gCyb/Sdktsj0mD6atNxpVYbD NpGcXBf/cTD8a4ZsJ/gAixDqj13Y3e8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-KTPUyLjDNq2xpVad29wziw-1; Mon, 07 Sep 2020 07:43:06 -0400 X-MC-Unique: KTPUyLjDNq2xpVad29wziw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BAFA1007461; Mon, 7 Sep 2020 11:43:05 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.40.192.127]) by smtp.corp.redhat.com (Postfix) with SMTP id 724625C26B; Mon, 7 Sep 2020 11:43:03 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 7 Sep 2020 13:43:04 +0200 (CEST) Date: Mon, 7 Sep 2020 13:43:02 +0200 From: Oleg Nesterov To: Davidlohr Bueso Cc: rostedt@goodmis.org, mingo@kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH] fgraph: Convert ret_stack tasklist scanning to rcu Message-ID: <20200907114301.GA31050@redhat.com> References: <20200907013326.9870-1-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200907013326.9870-1-dave@stgolabs.net> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/06, Davidlohr Bueso wrote: > > Here tasklist_lock does not protect anything other than the list > against concurrent fork/exit. And considering that the whole thing > is capped by FTRACE_RETSTACK_ALLOC_SIZE (32), it should not be a > problem to have a pontentially stale, yet stable, list. The task cannot > go away either, so we don't risk racing with ftrace_graph_exit_task() > which clears the retstack. I don't understand this code but I think you right, tasklist_lock buys nothing. Afaics, with or without this change alloc_retstack_tasklist() can race with copy_process() and miss the new child; ftrace_graph_init_task() can't help, ftrace_graph_active can be set right after the check and for_each_process_thread() can't see the new process yet. This can't race with ftrace_graph_exit_task(), it is called after the full gp pass. But this function looks very confusing to me, I don't understand the barrier and the "NULL must become visible to IRQs before we free it" comment. Looks like, ftrace_graph_exit_task() was called by the exiting task in the past? Indeed, see 65afa5e603d50 ("tracing/function-return-tracer: free the return stack on free_task()"). I think it makes sense to simplify this function now, it can simply do kfree(t->ret_stack) and nothing more. ACK, but ... > @@ -387,8 +387,8 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) > } > } > > - read_lock(&tasklist_lock); then you should probably rename alloc_retstack_tasklist() ? Oleg.