Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2030432pxb; Thu, 16 Sep 2021 23:59:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK4WIFexm4uKQuXAvaVoB7NR53dNBAOKPIsVOi5DrUaLF93po1SqwHEmZmuQfM3xED56OS X-Received: by 2002:a05:6402:4cd:: with SMTP id n13mr10856889edw.215.1631861950748; Thu, 16 Sep 2021 23:59:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1631861950; cv=pass; d=google.com; s=arc-20160816; b=NhWtZpSr1WAX+v2BrxexOoQoBGw44XME1SYRlGWLpccmBibOfBWXsbGzdH8cx6KoLw f2Bj7A+XBBLFOndFNC+UTeES16LJC33Bjj26c/apsjo5bKdN6M5sXLO9riAxUjYB5k2d Ea1REnzxJEWtwnjq3EQca2pR+3y25Xdw/3+BU6Dy+FNwwsQQ43+4pAqfZnt2M3DQss5i qNGTxFsczX1w4QHXlr15IfhdVcgtKMcbPF0NMWp95kfcg9PhIopzBtIbJWJEk/2t6vhy JQ0StNIp5CJeH2ieNFDbUpZqjiyhu7f6CLHC/WS5b8WxzINLx51BSZHp4jHooIBWFf91 DH0Q== 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 :message-id:date:subject:to:from:dkim-signature:dkim-signature :dkim-signature; bh=G4osKdktX/ZEqtQ4EpH1N9vM9fppqprnCvtuI1aUGoU=; b=VdDqKE7FJy6Oms3RVns7x2+yriXj4jRPgLCXGapUWKSWxF4YNzC4a2AVFoBT5NntT3 cZaD5pi+xjY0oiZfsyhcRsSfoUif6XilzqQqjVOQEoFbpfGC3dM5qP3S2LAd0XIC2ZIS HE0H73Aikc+Cm1Eup2ZvNnygurq1YqwG41dBybLqTPN19yO4tE1clwzbZP/hfcJXqS3f WRFU6vJkqwVBSomY9Kf/XMIac/ay+hW/5DcxuLXgwK1Uyw09mXWAYoXFgYJ3VJpTouHi b/o7Trz/Dchyevz5qalQXKr934NbypmjBXR2vwOW64lhFr43UQlVe6zwfaGNe5+Jezav +/6w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2021-07-09 header.b=zBJqtzGn; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=rqsTe+6z; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=rWdKwq4F; 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 nd33si6636335ejc.139.2021.09.16.23.58.47; Thu, 16 Sep 2021 23:59:10 -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=zBJqtzGn; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=rqsTe+6z; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=rWdKwq4F; 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 S239652AbhIPVWh (ORCPT + 99 others); Thu, 16 Sep 2021 17:22:37 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:46164 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232785AbhIPVWd (ORCPT ); Thu, 16 Sep 2021 17:22:33 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18GJu7YR019729; Thu, 16 Sep 2021 21:21:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=G4osKdktX/ZEqtQ4EpH1N9vM9fppqprnCvtuI1aUGoU=; b=zBJqtzGnSWZs/QgbZn69ldsQu0X7Nk/xoxJwtVRjy6pPJkmHhohG15opt3hPoWoedyPp ErupFlp4TZCZoswILGc5vxqGxMJaZc5V+I4x9PveR+o0b7WkFNCAmXiLDA4XckBWX/DJ w4vQcZNfFR7G8h8hqN3TDoyabBeqPjB8iB6oHWuZcRYYE+j943JedwyY60lAa+Y6vug3 0roskznRQU2r4+NVQ9iueyNDTY1RoWPAtKnp0PSnXusvc4NO+QTA8GpllLdJnSD3I2TY CssAH2Iit9+gVEu5tUWLEQzF8xYq5lBdxbakXThnBDjqj8iC9NYp91t8qEqS9rJv8fGL Dw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=G4osKdktX/ZEqtQ4EpH1N9vM9fppqprnCvtuI1aUGoU=; b=rqsTe+6zYp3q2Bj964XFlouVz0xfKbLeedoBatPwRVNFzWjwUbwpshVtZ52z+fAEws3C R2VQIzdW1+72zWbniA1eAwf8w49vQb7MytYYZvADqme9GeldQa2vK0mHkYEWbX0rMUIR kdWIZIhm17OEQO+Lg0jMHVil9KeCHvy9onFN9Ot4TLMvmayUHgSJBsOQuKufxgeFZYeP 99QGN50vICRTwGkcLcJ+7vJKxYlpzkfaRHhEAd5RmYnO/J0JV9KmpjdIjkXuO4KzV7FM zbarnXhhVhR8vM8MruAjKCs3hWxSqtV2EGM0WLpF1ccc9r8m5RzS3yj61yfkafGaZmKz 4w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3b3t92m6q5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Sep 2021 21:21:05 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18GL5XNn011268; Thu, 16 Sep 2021 21:21:04 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2046.outbound.protection.outlook.com [104.47.51.46]) by userp3030.oracle.com with ESMTP id 3b0hjyuvpe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Sep 2021 21:21:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZX7EFMKlm8EeSAZLILEPuUuCgonFDpLxYMIS8D05O61uUk2VHym3Mzm112ZVBFoTBlCGppsAqQTseX/pYU6TPSE3l9BYB2GTn5LBKtLjIs8b9Rr70Ul6PvY2PlRG1qWrS5RCiV2FjWtyQn3KQ/4EArbcNvTEfmDBnxIoX/1Un6zO83e3wZbuQ8NS3IBhF/dYMQK5jiyCTb6WdyUkskDFx4pTQiJ7+0SqoNXjeyWATXEAMIzfQV277mg131pAZEbJcV0gD5fQC4vSc1+MPIwcgL3+qopYdwFN7fQOPSD2coU9QtU/pGg8c0IoZgDIkVYA+xzMSWFj9d5GT1RIK6Ov1Q== 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; bh=G4osKdktX/ZEqtQ4EpH1N9vM9fppqprnCvtuI1aUGoU=; b=O75lcEdUKFSv6AM4O+eHRADdawTqVQiJ2DrB/kxS67KyfzIm3LF848nUYbbrMNpgKLzzHSHLr5rqZ82J5Wz0aJrpOpCYtiwAnac5ZM6+zk9f4ewJX8DLkZRDZHesdyQGe3K22YSGWN1VudXGEQkxTOmKVMD9QD9xVN554SQAQR8YS8/3QD7W5uy8RGBKGjhtq/0cgssJ/Q+EU2xNwBdhGexKcAOnDEljLN4kszRb/ma5hY0ZZYZYP7d+m5BNiEP992kFK9f78XezgBTV2f+l1qHDVQrEHj8vuibY8AuJKjgvtrnzpMNMvemRc7nfhFJwPGuTcc9GYoexpuUCZv0SYA== 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=G4osKdktX/ZEqtQ4EpH1N9vM9fppqprnCvtuI1aUGoU=; b=rWdKwq4Ft9vilTRYKGiuLeHQN5gQd9HnyI7J4EKETCoDKFMo+fYMSBT4T7Wjz7ItY9VnoMh4OlWAi6Ges1PrWl4z9XdFNXyn5vAjK85i7riViq0YVdJ16s6Up07Obi6/2SYvWjXO6kFCnNd3t0uFxtAZMQtBxmhJP4LA5Z1ExCk= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB2935.namprd10.prod.outlook.com (2603:10b6:a03:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 21:21:01 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::5881:380c:7098:5701]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::5881:380c:7098:5701%6]) with mapi id 15.20.4523.014; Thu, 16 Sep 2021 21:21:01 +0000 From: Mike Christie To: 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 Subject: [PATCH 0/8] Use copy_process/create_io_thread in vhost layer Date: Thu, 16 Sep 2021 16:20:43 -0500 Message-Id: <20210916212051.6918-1-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: DM5PR04CA0027.namprd04.prod.outlook.com (2603:10b6:3:12b::13) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 Received: from localhost.localdomain (73.88.28.6) by DM5PR04CA0027.namprd04.prod.outlook.com (2603:10b6:3:12b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 21:21:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b0f7061b-fc5e-4c1b-e0d3-08d97957e1e5 X-MS-TrafficTypeDiagnostic: BYAPR10MB2935: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Szz0ScDlZ4mrxKgZpi07Dk/6kMmWbieKZ1sDmo0Fnp6D/s6Wz5kClkmqnvOAtvt53qerae7KRM8Li5i0jjFSDGZMwBl4jTjMJXJnyRndF5uKJYp8tXRWD+D6jw07cl6UMsP/AEFBhbki8U/BTbYqSop9bFu+sE5zh4rY3Z4EdBImvWAMsoLTgidvzzepYgn6Qde5uFO03mLOE2HBwrzl1gcOnrvD4IhWyejJVDKnTP8gwvFdI7yVdXMHTMev2NK4JHkLBVu913VEI4Tu9SnKDObenorBKWthVGv7/MEAh2AcQg6nH9qdCDVbkoQr/46ATn6Zhz1p953JnzMqwhxjuDAabDFHynDN/7brcuaciaAEObPg4oW9yoRS4817ehfS/x7A29FUHme/itwL3R1zN1pgHmh4gROThxgoQKHOGd57TM6/Gl1sPq1bQHsGZ8dVCpIYirX/UVz5u/vucskEvcyz+czgplsswMP5cH9fQsfE9/kKjGVNh5WZICieWpVaAePVsXusJv891tRsqUT0QFdMhap5cIukWaApeKY/fm43t9fKBuTMWMDFZ5Je7LnVYQ5KL4BL++iU5sbOMfPRcDLfaN8yOZqe/41N0xtDntA5ni49RIiRxhP1gnCvJuoWpBzmD9jW7Ryubt2t/JZkDFCdv8k2JFYStF4C2tOVxuobUhSzduodEUs0LDBrtLPH/BqIbDRsTOG/Vr7bIKqtfUSDe6CUdXwW6INRW3HeLlOFuE1nDlDUhFhoBU9wNwJDFRY8AKH9MRKqaVmJNEr7Jw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(966005)(316002)(86362001)(36756003)(26005)(508600001)(8676002)(8936002)(66556008)(83380400001)(66946007)(5660300002)(6506007)(66476007)(6486002)(2906002)(38100700002)(38350700002)(1076003)(52116002)(2616005)(6512007)(956004)(6666004)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?bzOTk/8/A+ZRPIKu/9aYfTrvoGLpVCl19XnZIHtGVfyDtto4AFcsTmwuHj7R?= =?us-ascii?Q?ejaz72cgoidpu5ptfToMXPTXpUaW7c6mTkjCp4aiTqVAxgDxVs3CQVETaead?= =?us-ascii?Q?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+CCq+KUxri1?= =?us-ascii?Q?iTDG+UFByYsB9msoofDMqRAcdmVsD1eCq9J7xKeL1RLMyKJhyWs2XtpHiRH3?= =?us-ascii?Q?nOwCSxEpV4iU+qingzPumbZ3+siPyPm/hhqLHQtT/xyUJ7/dCq2CE7f3eE9b?= =?us-ascii?Q?t5v+82Xa0l2Qq8UG7BYwvewEehxhHVwX56DjpWrUXM6aEztW930RNZvkWCfH?= =?us-ascii?Q?OX5JZ1IREQEEpkqGxxT9fcVTpNlPSdIM9wI1BnfAAhTh4K2SudcGp2xAOPd0?= =?us-ascii?Q?fbwYyULttUiyilAWHQ/uIboV1/jRAKNodzyWXO9SOTpbTSJzx6LcwDdOD3Kt?= =?us-ascii?Q?6KNdiopJCkPF6QwTC1zsJCsL?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0f7061b-fc5e-4c1b-e0d3-08d97957e1e5 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 21:21:01.1119 (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: eIbnsfIC2+xJppu44z8x28LgZdtp7PRDNfH6/crjAwPIEJEEO/Xqfh3BirhnvYUe5ZEE896BKCM4A8YRjD1qZedly7vseY0sBpxgMemFET8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2935 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10109 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=621 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109160122 X-Proofpoint-ORIG-GUID: W97TARUWu4r82xKml8FbYpYlmkvDzqKU X-Proofpoint-GUID: W97TARUWu4r82xKml8FbYpYlmkvDzqKU Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following patches were made over linus's tree and also apply over Jens's 5.15 io_ring branch and Michael's vhost branch. The patchset allows the vhost layer to do a copy_process on the thread that does the VHOST_SET_OWNER ioctl like how io_uring does a copy_process against its userspace app (Jens, the patches make create_io_thread more generic so that's why you are cc'd). This allows the vhost layer's worker threads to inherit cgroups, namespaces, address space, etc and this worker thread will also be accounted for against that owner/parent process's RLIMIT_NPROC limit. Here is a more detailed problem description: Qemu will create vhost devices in the kernel which perform network, SCSI, etc IO and management operations from worker threads created by the kthread API. Because the kthread API does a copy_process on the kthreadd thread, the vhost layer has to use kthread_use_mm to access the Qemu thread's memory and cgroup_attach_task_all to add itself to the Qemu thread's cgroups. The problem with this approach is that we then have to add new functions/ args/functionality for every thing we want to inherit. I started doing that here: https://lkml.org/lkml/2021/6/23/1233 for the RLIMIT_NPROC check, but it seems it might be easier to just inherit everything from the beginning, becuase I'd need to do something like that patch several times. For example, the current approach does not support cgroups v2 so commands like virsh emulatorpin do not work. The qemu process can go over its RLIMIT_NPROC. And for future vhost interfaces where we export the vhost thread pid we will want the namespace info.