Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3910757pxb; Mon, 4 Oct 2021 12:25:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzu2ZszAWEMcy/YSxRy9z6u2tMuNgos7XuG+ItU4vZk24hMOPsrcCu9ructXlm9rjWz1YMb X-Received: by 2002:a17:902:e8cb:b0:13b:6504:7d20 with SMTP id v11-20020a170902e8cb00b0013b65047d20mr1283316plg.31.1633375531490; Mon, 04 Oct 2021 12:25:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1633375531; cv=pass; d=google.com; s=arc-20160816; b=QadnWWhrh891RFKGMoqzFEj6NAu5DnKAqDCuQk/SO5caS/qqZhil1PdI1vO48s2GZc EGRQOVi0PShdVXOSSEtm50d1ikilSjbmuRw0tSIe5tX1H4do1RqHEinOSB6N0crGa2RU +YNUbM75xfAY8N23/OWAmECXXfek8hG1QFkFyleeLipch6Pe5zPX33kkkIdMJSRYvwoC nWqI1paiGgDqRTEO1dbvLWaJ3C/HTiZxa78R2V5vpQRlDtbnIELi9ldTRpiQXgstI+KI UjY60+MHYpCnHp1jJcZOSP8t9WQ6dFU2UXYwf0pgXxPLOOdn56U1kMgM7g78NMoQdLDj L0VA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=yG4NO3ds3SUK5GdHkg0gecyx6SihjSiMbEungKPpFjQ=; b=TTlu2UwNuh/sa0XBWSgQsepjYTBj/n4V0z+XX4O9VWo0wdstdjH7FcvBXVl9xnTji+ KHt2bK3BZgbuDX/cUHtaceQKvjl4yjGCqK8UwqFun9+wq0guGCxcgAgWJhwOn12qLCQz uSbi+1QNDhfVdo0gM1nS29gFPSyrZ63KDtyoahOBr2JUQOz6IKIRcWAY/W80RlCgqIGo 1uCVFbAFhWS19Ge+fHiaEeSqgJfzXQdJ8yIMKxPqYh/q+Ukwje10NNqy6xxYqc2aHOXZ rSdNEtxBUAJRwHUki+jbv6CnWjEOdzfoK2djZbtMaEY5ngqH9i7yldatopywfDf3FgwD YmMg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2021-07-09 header.b=gaX1BqMJ; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=LgaXQtQm; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si10658414pfg.373.2021.10.04.12.25.18; Mon, 04 Oct 2021 12:25:31 -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=@oracle.com header.s=corp-2021-07-09 header.b=gaX1BqMJ; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=LgaXQtQm; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238977AbhJDTYd (ORCPT + 99 others); Mon, 4 Oct 2021 15:24:33 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:16256 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238708AbhJDTYP (ORCPT ); Mon, 4 Oct 2021 15:24:15 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 194IR8iO004481; Mon, 4 Oct 2021 19:21:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=yG4NO3ds3SUK5GdHkg0gecyx6SihjSiMbEungKPpFjQ=; b=gaX1BqMJWQDVh9ufDFIje2GBjVAadLUshiVzxEfZBOzPo8xswjHsAUYy+BCMooczLUd1 rSJl927cu/bbGLka6TOnREBBRb3FK6OnkMSpvbTGQgRT3JMovGXoSVnPub6eFKCWvw3x vPXRenVe/+A9/kCVu7N3fmJw4wdfmHDTWZx2sbwLEO2S5yVBvFqyH99bYwLFuMky+2Dq qucmJIxE2x2l0yLzuQNTrBx874bCd9PGkW2/ZVqxjrky4vnOfflTjGhzz/C5VQ7//El0 BcMfXSxpogjrTv6iqttdvf44lqaBy/TYL+15GwATBjCjdA4gfPh/tOS1PYkjGC3MeFNI oQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3bg43dst5m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Oct 2021 19:21:46 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 194JAbkr095280; Mon, 4 Oct 2021 19:21:44 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by userp3030.oracle.com with ESMTP id 3bf0s5c7jr-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Oct 2021 19:21:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j9xlqUsyPTDQYrS4Sq3V0CsvpsREWJbTC/P0CECNGlKuYS8zOSUinAzdaHguF2N8nyiAm0XGxdb2dUs/JKjU4btpo8mleVVafDmshjLtqVwf3vuqeaEGqV+7PgiC2JqxdxlUk+NhPFMeWV2BqAY4A+H6osZGT0rFU7Opb6XmX5EfM9g9xl9ZKRcvW8M7Uo1EVGVLYBBr2ZWLyXgwV4AyiqHC35AmZokiLh+u3bQ/ZA6T47a0yTJ2wONkVUKrhsoILjnb7A84LTI6rILRNGYLayyc2tCsuWkHXu0eBT0rJK21HmD+2GR4D7a2/5QRhSSvHhLxjCR3z5+CdaIT9mguxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yG4NO3ds3SUK5GdHkg0gecyx6SihjSiMbEungKPpFjQ=; b=TuQKLTdvYKuTEcovXINaA/fzvR870NKdywMR9vi+drTqylx1AOSOvQJ8ZAuNtBLNqODvLehyUm7MUXLCq6IBIwTxj6TIBEjZjWo12rc9DpbNAW4VAHoJJ6qEQcrPslHzQrEjOXLz9f1+N6O5nzBbI6ITRH+68zIVq0SeR7MUUmSte2Baz8sDb/i/GiozhvkKdSla76I2ErRZ8h89WsTOo/vw3Xk+QNkUVignA0cgCdlWDHyPQE2HpLHkoYEeuh19IbshOEds7XZJ1Iv9x1hWobQRFh9tF93IndWcreDe0lq/Zn9xOUZO6/3s3hLhAamAMj7/1l4Opb7HhDLTFmZybA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yG4NO3ds3SUK5GdHkg0gecyx6SihjSiMbEungKPpFjQ=; b=LgaXQtQmyQLCT3v1gJfrvSk/guBhn3Uf0aFBBa1XD6gplHd7D0bmLNtiXj1dGiIly4Pfh3z5ehhalnnF6vE40S6qVf8ey1KL16Y1ZCgjZMPZIuKsaZ5KMzXfF6XXCbwvvKSRoCIKJBMnrSX+eud1hfZz34ywPAnuoOaes/JKp2g= Authentication-Results: linux-m68k.org; dkim=none (message not signed) header.d=none;linux-m68k.org; dmarc=none action=none header.from=oracle.com; Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM5PR10MB1548.namprd10.prod.outlook.com (2603:10b6:3:13::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Mon, 4 Oct 2021 19:21:42 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::195:7e6b:efcc:f531%5]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 19:21:42 +0000 From: Mike Christie To: geert@linux-m68k.org, vverma@digitalocean.com, hdanton@sina.com, hch@infradead.org, stefanha@redhat.com, jasowang@redhat.com, mst@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org, christian.brauner@ubuntu.com, axboe@kernel.dk, linux-kernel@vger.kernel.org Cc: Mike Christie Subject: [PATCH V3 7/9] fork: Add worker flag to ignore signals Date: Mon, 4 Oct 2021 14:21:26 -0500 Message-Id: <20211004192128.381453-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004192128.381453-1-michael.christie@oracle.com> References: <20211004192128.381453-1-michael.christie@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: DM5PR15CA0034.namprd15.prod.outlook.com (2603:10b6:4:4b::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR15CA0034.namprd15.prod.outlook.com (2603:10b6:4:4b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Mon, 4 Oct 2021 19:21:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fe0a153b-0cb9-4213-ffa2-08d9876c3264 X-MS-TrafficTypeDiagnostic: DM5PR10MB1548: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1360; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /O9J52bJ1D9uTGxrLRBzWBvGNaM4nH62j4tjSnwXhchlZPG9pwwy3xZJ39bqf8fYFVrz8jQr32Sk5Pd5/z5Im27yXIkraMkFMrJ+38jTZepqUGuQmst3XAt8XOjfyXfy6jAd1jbeUDbB6+MqhBgMeIPxA8aFlm2AgRuspayTrlkvGmQA2HFeYB3+8xi+BvWKiLkuUi0IbbJwDpqMN7MFxTBdHOEs0IAL5sYoxtn+RMfl7caXjvwcRgNOyPMF0pfV/bl1+FsNNubiFFilyfQuowocBGeYQLoc+8oE4gCJ0wkd7kLBr+4h+zV2ak7Vzgm8h/t/yxUtRAdhd2gswfKHY7CMYcPkXqI0I3Vq6F3S94whO21JYkevXmyA9RUj0gI0KfPkll+w7wSWfHW9SzNtq9hnaeZaHOHbR1sP+X956BtzmsK0b4c+ynXgCUoBeK/cn3uwXo9NiJlktRokl+BUNgRgg+K27gKS2VXjE76lo13b35uGIgEwY7kEzMAYjE2LSyp5DBiVayJroUkNWYzZrcCiu5U6SIfly25Xxnw+IIHBFBPAP+vWYy7UfKrlWlP49XbmWZWrFUexpkDuZ1UWW7sqvR7lOwWRhhJN7pVuxF+yV/mkfvj8p8AGaAhLa7TOkvrTfkTBEhc3tKSuFBjA0dFvKgq9CTmivlKtstnNyF/5imcwNLcfRsPecaP8/ZY2qiW7toX5K80ZYRqWhjka8+MFUhEzB3VpMTD3DRkke2k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR10MB1466.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(83380400001)(8676002)(921005)(7416002)(186003)(38100700002)(38350700002)(6506007)(8936002)(4326008)(26005)(508600001)(2906002)(6512007)(6666004)(86362001)(316002)(52116002)(1076003)(36756003)(66476007)(66556008)(66946007)(107886003)(2616005)(956004)(6486002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?fb1o2BP1/EXevwYNxePdt0LbtrB4i1vInrHg2iCVgpZpKDEwHemHfTZ8+pzm?= =?us-ascii?Q?aMRmK/Qbb6EpGQC0iXswzt88WdcYhIW2YTbhZynk3JqI9SAuxBEC79/8KT6U?= =?us-ascii?Q?NWsDRs1f4a+7CMxvVUPLWy6LAGr8zY11lSYHAX+u8pjSmotXdHxL8LzcvOwC?= =?us-ascii?Q?mOJLeeJD7g7WvcwoqOP70lnHmqvlDx2XMbIWDQSevVssm/+AzDF1arV4n9B9?= =?us-ascii?Q?2id/1Lhj/ExsSZqxiDuWn6b2jt4Iv0bbLsHf9j92VSkVzT0My2thgQoaFoLh?= =?us-ascii?Q?PMScU/mddsMeC+nZosLCVeoBPdnj4uJcjsoWmo1txQ4HzwEXR2jTsmF8mBB1?= =?us-ascii?Q?TM3jtwtB/rnuWNlqOn+UO8YOj//LGlV6ws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li0I56wmkYTM0OvJCn4e7ERJ0PchKhK+GMDd27bZaBvH9fnSWPrrnMHN?= =?us-ascii?Q?QOia4xu75dLimQ9TNB4TzDaQ?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe0a153b-0cb9-4213-ffa2-08d9876c3264 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 19:21:42.2812 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eaIprhTByqsLVm1EcW/mitElPCI+/WpuYcHFwGHQsssxUwu3L4w4jpgzN2MCSxJuviDCPoEYhnc4SdCwy53XtmkUgGHlar8NisBfJDExhiU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR10MB1548 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10127 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110040131 X-Proofpoint-GUID: jXxhT5Pc-wXPFq5CUUyMxu6dFucHhroT X-Proofpoint-ORIG-GUID: jXxhT5Pc-wXPFq5CUUyMxu6dFucHhroT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kthread API creates threads that ignore all signals by default so modules like vhost that will move from that API to kernel_worker will not be expecting them. This patch adds a worker flag that tells kernel_worker to setup the task to ignore signals. Signed-off-by: Mike Christie Acked-by: Christian Brauner --- include/linux/sched/task.h | 1 + kernel/fork.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index 781abbc1c288..aefa0d221b57 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -21,6 +21,7 @@ struct css_set; #define KERN_WORKER_IO BIT(0) #define KERN_WORKER_USER BIT(1) #define KERN_WORKER_NO_FILES BIT(2) +#define KERN_WORKER_NO_SIGS BIT(3) struct kernel_clone_args { u64 flags; diff --git a/kernel/fork.c b/kernel/fork.c index 3f3fcabffa5f..34d3dca70cfb 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2555,6 +2555,8 @@ struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node) struct task_struct *kernel_worker(int (*fn)(void *), void *arg, int node, unsigned long clone_flags, u32 worker_flags) { + struct task_struct *tsk; + struct kernel_clone_args args = { .flags = ((lower_32_bits(clone_flags) | CLONE_VM | CLONE_UNTRACED) & ~CSIGNAL), @@ -2564,7 +2566,14 @@ struct task_struct *kernel_worker(int (*fn)(void *), void *arg, int node, .worker_flags = KERN_WORKER_USER | worker_flags, }; - return copy_process(NULL, 0, node, &args); + tsk = copy_process(NULL, 0, node, &args); + if (IS_ERR(tsk)) + return tsk; + + if (worker_flags & KERN_WORKER_NO_SIGS) + ignore_signals(tsk); + + return tsk; } EXPORT_SYMBOL_GPL(kernel_worker); -- 2.25.1