Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2858158pxb; Tue, 9 Mar 2021 12:44:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJysI70iSw25FXoKm1TKa5yqrMaTFk39xRUsJ5NDe2GaAw+cCB0QJkvpkxXhM7IxWzDPDfkX X-Received: by 2002:a17:906:d19b:: with SMTP id c27mr21910844ejz.304.1615322660013; Tue, 09 Mar 2021 12:44:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615322660; cv=none; d=google.com; s=arc-20160816; b=Xju9bZgnOllF5n0+Qyen+yHHEfK902jW++/yhKQBuQ9QtJDTCR+CPrV8EAlnhcsv7M 3hUeGzFt6ZmrttYDP37ZJM7Qy3ObS0bU1Pqit3pM+8IrsYZBQja98FepIeaJ5wa9TYb5 PHRIiLudgCE6EuYyqE7CJPaXQL+2L2SO2RbGrEYxakWEHwVpteBBFxeGg/obNiX4x3fh OK6A3y+NzjI5fQ21bEmtHJm1dEZsvYOgOgHTa+YWfkRbqecjLVKyNS7dpvPMgondBSNu SZjv9ddcsO6VbNsI8T7wJ+Y44kIfvBKO/mQThJLx3abEfuYwH86/bvXM1sycbsyUE6es lceA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:date:message-id:organization:from :references:cc:to:subject; bh=Kkc/49Yv+v7l++gYmLIvwBHHQ4/73oasvc/L1/N5a74=; b=cvHc6aF4z3iqHuOFrBQKbJr9YgFWNMI8yhQZIDSMeXDs+PrHpYQDojvmFEdyBP7mNi Y9iEI1sFzanydCf/+heoz66IVW9P8nNRbMT5QO6uYrXu8MbkrSo2Ubv7Zt/qHp2+lNlE RgvIcEg6KbF2qGpyzQ2TrWMvszZlanhaGuIV0Q3EumOA6XOoJ401mrBvJMvuj89z7Zqe ko+rK6mEnRKeOfvULnfOJSyTfxLRVaVm4dC+6Ct2dCvKqnGuiOliL9WiHILjz0JwDKcR bssenYHnBtHCmIg4e9wXtOR+WQ3SU/D0LcgWvyDgQ8kONxjnyn0w/EgrDLY3s0qe8PEr XzVw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si7737616edr.72.2021.03.09.12.43.56; Tue, 09 Mar 2021 12:44:20 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231867AbhCIUmY (ORCPT + 99 others); Tue, 9 Mar 2021 15:42:24 -0500 Received: from mx1.riseup.net ([198.252.153.129]:43536 "EHLO mx1.riseup.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231864AbhCIUmD (ORCPT ); Tue, 9 Mar 2021 15:42:03 -0500 Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Sectigo RSA Domain Validation Secure Server CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4Dw6Zg43B6zDxYR; Tue, 9 Mar 2021 12:42:03 -0800 (PST) X-Riseup-User-ID: 6E80CF5FC8EBBAAF70C42356D782147E33F6E50F79F7ED969E5F47FC70B30D58 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4Dw6Zf6Zppz1y6Q; Tue, 9 Mar 2021 12:42:02 -0800 (PST) Subject: Re: [PATCH v2] do_wait: make PIDTYPE_PID case O(1) instead of O(n) To: Oleg Nesterov Cc: Andrew Morton , "Eric W . Biederman" , Christian Brauner , linux-kernel@vger.kernel.org References: <20210309161548.18786-1-jnewsome@torproject.org> <20210309171539.GA32475@redhat.com> From: Jim Newsome Organization: The Tor Project Message-ID: <7f5508ef-dbaa-fe5c-9826-cce0122eb2f8@torproject.org> Date: Tue, 9 Mar 2021 14:42:00 -0600 MIME-Version: 1.0 In-Reply-To: <20210309171539.GA32475@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/9/21 11:15, Oleg Nesterov wrote: > Jim, > > Thanks, the patch looks good to me. Yet I think you need to send V3 even > if I personally do not care ;) Please consider ./scripts/checkpatch.pl, > it reports all the coding-style problems I was going to mention. Thanks! I'd thought clang-format with the included configuration would be sufficient, but apparently not :) > Both if's use "int retval", to me it would be better to declare this variable > at the start of do_wait_pid(). But again, I won't insist this is up to you. My usual inclination is to avoid uninitialized variables and prefer putting them in tighter scopes. I don't think it's really much of an issue in this relatively short function though; happy to go with the prevailing style. > I am wondering if something like > > static inline bool is_parent(struct task_struct *tsk, struct task_struct *p, int flags) > { > return tsk == p || !(flags & __WNOTHREAD)) && same_thread_group(tsk, p); > } > > makes any sense to make do_wait_pid() more clear... probably not. Yeah, I lean slightly towards the extra level of indirection not being worth the deduplication. I made a couple other small changes as well: * No need for do_wait_pid to take the parameter `tsk` since it's only ever called with `current` * With that change, the declaration of `tsk` in `do_wait` can be moved into a tighter scope of where it's used in the loop. v3: https://lkml.org/lkml/2021/3/9/1134