Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp959560imi; Fri, 22 Jul 2022 13:36:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sHsLPyP+dfnuPeJguG4s+6R+HmzGIr0tDMAWToi9pcgsoul+bSvHhpiTf701LZTcWBBdRS X-Received: by 2002:a17:907:3f29:b0:72b:91df:2c4b with SMTP id hq41-20020a1709073f2900b0072b91df2c4bmr1272919ejc.206.1658522180165; Fri, 22 Jul 2022 13:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658522180; cv=none; d=google.com; s=arc-20160816; b=OdZsjQu74tkstNEJFyNVZ3MuUj4Lmzw+pEmiTqdWdQtYilppwsTyKMJfBb8S80et8x yz+DF/fTzd7lSRhOrCvOFtm8Uwcl1KTwhOQu+yzRl0zdMNNrGB+ttRWpSaVc2ESKE68+ ANSsaX2YUdevdo01FNckpZLAFv7N4Wyblu+0b3/P9vVjcn341yTJWsk1ETHQHC3RlRrh t8RwYsP6KR9W8RRnqRHkapLGVZaqsNH/cUYmOhuVMNfEDrzCoQEyMdSe9A1cI6K0ED1b S2gzG/jItEbENjIrXGCqQePIoOBHbcqubayO2AYlHrXgcEe3F/+asX2xtTre8i95ATTi yxVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=8j0f8kcDZKNlClj0tfXDBIvaZa8cH3iU8GMAMU1+gOA=; b=VfX0WVuVrT3ymNn23WnI3Q75s2lo2+bJRZ+qCNPILg8PJ5/4eg5oDW63mnBXjzedhF LIar97BjpO88Ojzt8xZTf60dgsa6wvKKzjudNZFwUQKvNkwSzuWKYXnOE/Mdy0Xa97Bs Qdo1wObaS9GrNBIKoPFMAA6IGi8lu5xeuPfvYzLUI9whBrJebeG+hRKzEJs4nCy3+Ogm eaBgR+eAvxtGesz3DmXMr2gAP5oGPA/PRggu1ux3Z/PlvWjbxr4Zx5CpOuZnxyBT902U 1bhbhucLrFLnYWvl00YLarhNmOE5TZy8hNGUUQ5qcxetCig9iK6Z30TkTP5uo5Rlfc+h UOKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=q6qoXTr6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb33-20020a170907162100b0072b4a6fd638si7556998ejc.543.2022.07.22.13.35.55; Fri, 22 Jul 2022 13:36:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=q6qoXTr6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236771AbiGVUPT (ORCPT + 99 others); Fri, 22 Jul 2022 16:15:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbiGVUPR (ORCPT ); Fri, 22 Jul 2022 16:15:17 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D83A16475; Fri, 22 Jul 2022 13:15:14 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id y4so7086024edc.4; Fri, 22 Jul 2022 13:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc; bh=8j0f8kcDZKNlClj0tfXDBIvaZa8cH3iU8GMAMU1+gOA=; b=q6qoXTr6dfiDJ0nyok8qUoXLu2ys9+yRIy9fRN3v3yq0eKGqjwpaOOYNBafQO+usLo fVJ7FwTywsy+RYGwnRLnZUuVHhVc2wLR5NsE3OB2PNUYT9GmOLNKPA+/xNTUHF7X2yYg evJjMVBDJHlUugF5xntkXgYbqkTIPFF3CzyhBleq/yUfdJpeF/t4ob84o2nl2v6Ote2d D2iILOFx6RYsywwSvRYVqbS1gsgOZrPsb9Ie+2ddLV8DDQToBgtgK+p+aOolqyfPd+u9 cfWNaj2MYz3/lySlO7GW5ngsbRaxbLupOXk2qtJA1m8dah8SjJFravZNN7+Nzt6690nr lSPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc; bh=8j0f8kcDZKNlClj0tfXDBIvaZa8cH3iU8GMAMU1+gOA=; b=pjwcg7u5N9mn7ASAfy3NyExqNZbK7i99xD/HXdI7sd8SP+PBLiY9FazJLqps+w/vRb g1eMq3i6CdZCdYTtqJmjqmEzCJ55HjuyfuZHg0L5+VscdG7IFjYn2P6F9F7BZ8o9Epm4 p+zN4pd4iXbI8yly3a8O5j1AbmCMZvzUHpEGHJ2pYqofBi9QjoEmbGNcZfR3YtmGjsFy 1y4/q4Q+W2yMUrcyvZrQIVG7JD/W7MU22oDyAmJvfodiqoX6cpMj4njlh6/Y67uuvG6X dHue/IE0rgyWNflf7buEmo0Ux3V2iBGgE93hiZfinG4zNGiMpivbu/4IrkYUP7xn3Kmh AKmQ== X-Gm-Message-State: AJIora9ibLIcurYlIiVM4xWkKXTmcy4T+/kQnrcgqPRzyZCBgBI1GBFY /3yjj5ahCf/7m+lnC7MCQm4= X-Received: by 2002:a05:6402:1117:b0:43b:c965:549e with SMTP id u23-20020a056402111700b0043bc965549emr1493693edv.366.1658520913332; Fri, 22 Jul 2022 13:15:13 -0700 (PDT) Received: from krava ([83.240.63.177]) by smtp.gmail.com with ESMTPSA id w7-20020aa7dcc7000000b0043a83f77b59sm3008685edu.48.2022.07.22.13.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:15:12 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Fri, 22 Jul 2022 22:15:11 +0200 To: Lee Jones Cc: Yonghong Song , Jiri Olsa , linux-kernel@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , KP Singh , Stanislav Fomichev , Hao Luo , bpf@vger.kernel.org Subject: Re: [PATCH 1/1] bpf: Drop unprotected find_vpid() in favour of find_get_pid() Message-ID: References: <20220721111430.416305-1-lee@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 21, 2022 at 09:58:00PM +0100, Lee Jones wrote: > On Thu, 21 Jul 2022, Yonghong Song wrote: > > > > > > > On 7/21/22 5:14 AM, Jiri Olsa wrote: > > > On Thu, Jul 21, 2022 at 12:59:09PM +0100, Lee Jones wrote: > > > > On Thu, 21 Jul 2022, Jiri Olsa wrote: > > > > > > > > > On Thu, Jul 21, 2022 at 12:14:30PM +0100, Lee Jones wrote: > > > > > > The documentation for find_pid() clearly states: > > > > > > typo find_vpid > > > > > > > > > > > > > > > "Must be called with the tasklist_lock or rcu_read_lock() held." > > > > > > > > > > > > Presently we do neither. > > > > > > just curious, did you see crash related to this or you just spot that > > > > > > > > > > > > > > > In an ideal world we would wrap the in-lined call to find_vpid() along > > > > > > with get_pid_task() in the suggested rcu_read_lock() and have done. > > > > > > However, looking at get_pid_task()'s internals, it already does that > > > > > > independently, so this would lead to deadlock. > > > > > > > > > > hm, we can have nested rcu_read_lock calls, right? > > > > > > > > I assumed not, but that might be an oversight on my part. > > > > From kernel documentation, nested rcu_read_lock is allowed. > > https://www.kernel.org/doc/Documentation/RCU/Design/Requirements/Requirements.html > > > > RCU's grace-period guarantee allows updaters to wait for the completion of > > all pre-existing RCU read-side critical sections. An RCU read-side critical > > section begins with the marker rcu_read_lock() and ends with the marker > > rcu_read_unlock(). These markers may be nested, and RCU treats a nested set > > as one big RCU read-side critical section. Production-quality > > implementations of rcu_read_lock() and rcu_read_unlock() are extremely > > lightweight, and in fact have exactly zero overhead in Linux kernels built > > for production use with CONFIG_PREEMPT=n. > > > > > > > > > > Would that be your preference? > > > > > > seems simpler than calling get/put for ppid > > > > The current implementation seems okay since we can hide > > rcu_read_lock() inside find_get_pid(). We can also avoid > > nested rcu_read_lock(), which is although allowed but > > not pretty. > > Right, this was my thinking. > > Happy to go with whatever you guys decide though. > > Make the call and I'll rework, or not. ok, I can live with the current version ;-) could you please resend with fixed changelog? thanks, jirka