Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1609811rwo; Wed, 2 Aug 2023 17:54:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlG6CVsaxnj6q4W2LgMBcaAi4tdkALCoO5CbZfN4brdSjRHSwNMl/m5ps2M1TIskLZvf+9gs X-Received: by 2002:aa7:ca54:0:b0:522:38f9:4d5b with SMTP id j20-20020aa7ca54000000b0052238f94d5bmr6166581edt.18.1691024081033; Wed, 02 Aug 2023 17:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691024081; cv=none; d=google.com; s=arc-20160816; b=bVOQQ3Khmmdv+XizTyYSg8mUBqc3LPGfdDv607Zd4LXqVi4hpXyx+0A8eeAgs4L8tV S+SLbF07jdYBT6Rul1Payg0skpM1DFucGDh6loNVQnhOEfEp8VxKi3NPyBcavL3Y9THq 0aU0ss3XaZC6UtL+M3BlwIB+Vgkhjt9JoCchvNFmQCIsqu0QPmExeR0j7G/AmxuzhwWk SGnMIiGMPl0RpyoSJlgjG9guV40ei9cSmEwLAOFXyTLIHHsW6arQdjugmZFF2MX8ZsZ9 zjA59U6GnVW1xkQpGqfNAT2cRUyk9VxCcD7zihTJsAw2wwuYFLXMd8gii4KuqS/fys+N f6kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=C9zc53z+/V9/ECV3tKzh/T4s2rLLXca0QnmcU/Zn8AM=; fh=p+wOSmeLusTVqUKR8aQc56XBO9QP4vSQ6AXDIQF3284=; b=lIzRrvzkVO2ZU8TgbwVc5TJybjdcyUfyvFs9pjgGor3otCIVO5RVWEHGQ32rz3fJru O9jUtavRaPuX9M0hI39ACDpzf688cqUjScFlpp49XMQ6KOMuE39qrkboKFT0/l4xq/6T PLZc2KJ9vscurk4QCtfzkdvAoCxeYz8QWzsppjUKog0307mp0j8jQZbxRsR/qQZXvbuJ uHq4eYH+H0ytumsBERaBB1BH26cWfJHASRotilIfzq62NFQXC1vOGXpHWpHKh4NS+XzH qP1QnxITgsMAeDKrZZVCN3oTiVGAWdp0dJafbKzIJpE+5gQYBB+BTHn+8nnO6dlwZSSC bm3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=ev+WS3qa; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020aa7cf8a000000b005228273ab65si11523778edx.550.2023.08.02.17.54.17; Wed, 02 Aug 2023 17:54:41 -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=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=ev+WS3qa; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229550AbjHBXPZ (ORCPT + 99 others); Wed, 2 Aug 2023 19:15:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232633AbjHBXPR (ORCPT ); Wed, 2 Aug 2023 19:15:17 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC1F530DF for ; Wed, 2 Aug 2023 16:14:52 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6872c60b572so72547b3a.1 for ; Wed, 02 Aug 2023 16:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20221208.gappssmtp.com; s=20221208; t=1691018092; x=1691622892; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C9zc53z+/V9/ECV3tKzh/T4s2rLLXca0QnmcU/Zn8AM=; b=ev+WS3qaydOlkCo+QeWAPNPNHOvDvLz5rDIt+FcjMulT+GD53Eu9fsndQPFqHbDgXJ mw283KDuVisSntJFefGF8SIPSxPd9f442R6XxDH0n6hi23KGuugxfAfcEvTbF/HIC+Vu Sn5dWrcPzQ4zKVjPfWEOtZEfB48Fdg+a1WihE30oh/hjsk5vtGYpTIvBwXeqY8X8qquI NmD183MSlVg2qxSIgViiM76fbjawy/rg+taIIGQiTF6zpLCcZQIQQhxTJDzVXBnNAxmv wyE928xlSO/4VQ51BL5c5b99xLg3hcgEfOJ6ZOtOnvVTX7CoRTSbqCjJSfiksRbnuIzG lX+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691018092; x=1691622892; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C9zc53z+/V9/ECV3tKzh/T4s2rLLXca0QnmcU/Zn8AM=; b=mHIHxQA4yOrraajc5VrSXXCU7y5bv8HlOOgvdkGh1gjV7OzaAzoNNqghD+6VteuRW6 CA/fHHYxvQd92+P5lRRRjKguFg9Qk4fuRrTetKXJ0+YHVgjMoPQ519uncWxYtpoly3i5 jQLcmoj9JKVjNexd1dRB/fStY+1cEixb6Yyt/nWCfFSuJ/CrLnX9qHbnGs/kwBaXoZ6m 2cBOkq89h5bhaF4/VDOKBc0gXXs88RajQxJA1weM8o4+HwTpp+A5NAjHhqZKkPZVQI4c uB+6SMZl7DlMgSIkfJwo7VDFAx0wiWfKJ4Oi2y1vHzz0z9m5UpIXarj2JOG0q5NGeGvV 3VMQ== X-Gm-Message-State: ABy/qLZB3KpFGNLBCZhm9Kk5CT+CjqNzZ0kc+XOMzNNmO2QfQUNlpOiI J39n43Sa+0ADagMT2xcz2VAenA== X-Received: by 2002:a05:6a00:32c8:b0:67f:7403:1fe8 with SMTP id cl8-20020a056a0032c800b0067f74031fe8mr14821176pfb.3.1691018092005; Wed, 02 Aug 2023 16:14:52 -0700 (PDT) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id s6-20020aa78d46000000b006871859d9a1sm8588086pfe.7.2023.08.02.16.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 16:14:51 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Cc: brauner@kernel.org, arnd@arndb.de, Jens Axboe Subject: [PATCH 4/5] exit: add internal include file with helpers Date: Wed, 2 Aug 2023 17:14:41 -0600 Message-Id: <20230802231442.275558-5-axboe@kernel.dk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230802231442.275558-1-axboe@kernel.dk> References: <20230802231442.275558-1-axboe@kernel.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Move struct wait_opts and waitid_info into kernel/exit.h, and include function declarations for the recently added helpers. Make them non-static as well. This is in preparation for adding a waitid operation through io_uring. With the abtracted helpers, this is now possible. Signed-off-by: Jens Axboe --- kernel/exit.c | 32 +++++++------------------------- kernel/exit.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 kernel/exit.h diff --git a/kernel/exit.c b/kernel/exit.c index 8934c91a9fe1..1c9d1cbadcd0 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -74,6 +74,8 @@ #include #include +#include "exit.h" + /* * The default value should be high enough to not crash a system that randomly * crashes its kernel from time to time, but low enough to at least not permit @@ -1037,26 +1039,6 @@ SYSCALL_DEFINE1(exit_group, int, error_code) return 0; } -struct waitid_info { - pid_t pid; - uid_t uid; - int status; - int cause; -}; - -struct wait_opts { - enum pid_type wo_type; - int wo_flags; - struct pid *wo_pid; - - struct waitid_info *wo_info; - int wo_stat; - struct rusage *wo_rusage; - - wait_queue_entry_t child_wait; - int notask_error; -}; - static int eligible_pid(struct wait_opts *wo, struct task_struct *p) { return wo->wo_type == PIDTYPE_MAX || @@ -1520,7 +1502,7 @@ static int ptrace_do_wait(struct wait_opts *wo, struct task_struct *tsk) return 0; } -static bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p) +bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p) { if (!eligible_pid(wo, p)) return false; @@ -1590,7 +1572,7 @@ static int do_wait_pid(struct wait_opts *wo) return 0; } -static long __do_wait(struct wait_opts *wo) +long __do_wait(struct wait_opts *wo) { long retval; @@ -1662,9 +1644,9 @@ static long do_wait(struct wait_opts *wo) return retval; } -static int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid, - struct waitid_info *infop, int options, - struct rusage *ru, unsigned int *f_flags) +int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid, + struct waitid_info *infop, int options, + struct rusage *ru, unsigned int *f_flags) { struct pid *pid = NULL; enum pid_type type; diff --git a/kernel/exit.h b/kernel/exit.h new file mode 100644 index 000000000000..f10207ba1341 --- /dev/null +++ b/kernel/exit.h @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0-only +#ifndef LINUX_WAITID_H +#define LINUX_WAITID_H + +struct waitid_info { + pid_t pid; + uid_t uid; + int status; + int cause; +}; + +struct wait_opts { + enum pid_type wo_type; + int wo_flags; + struct pid *wo_pid; + + struct waitid_info *wo_info; + int wo_stat; + struct rusage *wo_rusage; + + wait_queue_entry_t child_wait; + int notask_error; +}; + +bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p); +long __do_wait(struct wait_opts *wo); +int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid, + struct waitid_info *infop, int options, + struct rusage *ru, unsigned int *f_flags); +#endif -- 2.40.1