Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37399314rwd; Tue, 11 Jul 2023 13:48:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlFLrMYAUhTNGvHz4A+c8YgCUcwD8sAT3GnPIA47WzhE0MSMNdjqF5WTv8T0/oZszJVDdurc X-Received: by 2002:a05:6358:5e0c:b0:133:84c:a085 with SMTP id q12-20020a0563585e0c00b00133084ca085mr15810295rwn.1.1689108504248; Tue, 11 Jul 2023 13:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689108504; cv=none; d=google.com; s=arc-20160816; b=NpuvoyaafCpADxvowK8DsrRYoiH02B3Iqt2qE8dTWvSF664TrTfzeTKoMyhJHaoc3k JIIzc4KskQlBtOg4d2F55oSqh0JhQGxHtoprV7LQyKi/6PYfslaPHWE+Mqc83bFTuIAB FnNvK7Yhv2sl3eH6XVB7CdDLuCiJuEiujAaFtmz8XhAmYfGpfVsVHZaRSHZGmzF3/Fbm XDg7xsjOeNsdZL8acbbJI72wxcJsEibSnHG40WOPXInsj62yrCw67NCJL2GJ1XfsXwS+ 3e01RKm840grvfB62l5nR6cAynyO2ssOhLWMOIGoN4cY0fRv9N2ihmcOnMjvi9qUZNqH MJQw== 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=SBNvf0wGJTmaxpDGBrc8F+lNIMH7WNrFQoZTkkuSHZZPoDI14b/pMAoeBrdtzlvwYu pm5559G0RhbsG+0Jol3hbQrRq7MdwgopxwyMRGP553BUEhU24W+ibbvJa44rsk0vj5f+ TgT6huUhaopywfYNhCcZAqcqXRBImUJo21pjsqU2uz75+zwvWy7iBBqkDVd8aqcFGY8E Pcuv6C1JHBJ5c0da/fZ6xY7QrD1ljyql/3Q9kIK3e6/boO/3c+BfUflDTsK5SQt9OmNh eSFLJajoTO4gc5x/yjQ3C5ZPiipw/+8Tq4zGrO2TipmZg3yl386wIbHyFZnalFwIVgdY Gz0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=4stpGtuZ; 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 c5-20020a6566c5000000b0055c0477e26dsi1851076pgw.475.2023.07.11.13.48.12; Tue, 11 Jul 2023 13:48:24 -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=4stpGtuZ; 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 S230006AbjGKUoO (ORCPT + 99 others); Tue, 11 Jul 2023 16:44:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbjGKUoH (ORCPT ); Tue, 11 Jul 2023 16:44:07 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F0C81710 for ; Tue, 11 Jul 2023 13:44:04 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6748a616e17so1602713b3a.1 for ; Tue, 11 Jul 2023 13:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20221208.gappssmtp.com; s=20221208; t=1689108244; x=1689713044; 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=4stpGtuZn7oMLOlDScS37tR4LbmPlFNAC023tmFK1/0CFyIBw0w4A5dau++EKDbUcT ujMsJ7PJofZSUz6kakzpmFt4T3MOOWrdKDgumuKIa0qo29UaJCdMBPCqUKMjBbnuPbMy 1kUratjfGG5pFsUfdUNIUKYG0s/yyYkSr1sIOWjZ0usCzVaBaf4/jXnyrtb0n7dxfUU2 LdnpD/cMhpPlEsp23nUsqMDSNEkkHz5GFPnKGCvwaZFOT31WMZaXOykDMf5keT6EtMF6 FYA59OuZmBp8EN/8e6xd0w747SZ4CksKsINtcvUbHcnrAG7m2vKKPcWbhPBOVhFbxq09 e3zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689108244; x=1689713044; 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=bSpBybGUT/r2NP25qTDp+fRHN8zUrBOtPBO2Dbg/XRSZRXbB6W4p1VDeFo0e+/aXUI 06tf1y0Rl3PYD3BW3MpNLml+gpVTCoNckydI7xSAgQFTULvnlGwZjh7mwn9DxrIR1Gys Yvi8rY57MIZ6J4jIIWXH0aJA48Turx6HpaErsCo0Oz0p/SmQDDhlaPPGde72Cpg5qWEk 9Q6+yf1NZ6wvJUlVBeqNRXH6EWnqeDbtStnEe2cRb5YmeERFqRfxQv23r8MXxcghFDWL 9lXAfXkA/JFeC7wsg0rKh60/mOeKXQs152nx90Apig9ZcQGydk0d15reKbS+wTwdsXgZ 8BPg== X-Gm-Message-State: ABy/qLbJ4pqLFZXxo0JEQIn4GITBqungwNH6K2Pk8QFMExa/szDnwXPY 29OHBhgwpUL4aD5q9tPoKUhUSg== X-Received: by 2002:aa7:91c9:0:b0:668:834d:4bd with SMTP id z9-20020aa791c9000000b00668834d04bdmr17735349pfa.0.1689108243811; Tue, 11 Jul 2023 13:44:03 -0700 (PDT) Received: from localhost.localdomain ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id f7-20020aa78b07000000b00640ddad2e0dsm2124461pfd.47.2023.07.11.13.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 13:44:03 -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: Tue, 11 Jul 2023 14:43:51 -0600 Message-Id: <20230711204352.214086-5-axboe@kernel.dk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230711204352.214086-1-axboe@kernel.dk> References: <20230711204352.214086-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