Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1023413rwl; Wed, 29 Mar 2023 11:27:57 -0700 (PDT) X-Google-Smtp-Source: AKy350YnoZfYj4O0eBowryWdSNND1J54ibeLTLSRktQmueLLSJl/9ACKFmQz6fxalggFJfYohf1x X-Received: by 2002:a17:902:e812:b0:19c:e440:9256 with SMTP id u18-20020a170902e81200b0019ce4409256mr25232277plg.35.1680114477664; Wed, 29 Mar 2023 11:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680114477; cv=none; d=google.com; s=arc-20160816; b=QCDskrZkrRUBvcmHQgLZsChPwJTbIJJr3WNbQOB+XgSmmKfl/TyWYLdJJDM4/i+bEK aurfz9Rq0RcadgY3ENP/4Gt6a9m4PDvcpiSEdG10AS2Hkm8fFRrkWq9wFcLp4NyDYaPG d0RJ+aeebZ3fgr3Q5Hf0x3pBmhSA/5ap+kZpyXlG/igQrMXE6OVxHkhWfV+T7DN3U7cp fj5pj6sC1PkgvKoo0ou3xOGbpYTGVmwwLfEsKZj/I2Kk+XTFzvp7m86vK5MV4meUK7Cj 8ZESLS9i6cqZ+pLG7kVvVlIddp/oYhw2qsjgjRLMty0hQl0JhSa90+N3PtKAwEpKuCLB 9SQw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Lzu4UVcTLXuXtHWcBLcWf277KyG7v5zkXe3TdU4cGyA=; b=q7Pf/MpKKsaveLXBL9R4uqFbE69hlq3DGppaDG+ycKYz9WUUAirIPSTa39epJRutU9 qz5+umZsMSZnYjLBOwYVi4QCB4+09nlh66YaMKMoytoQRCBqQyZVZQ07h1tuqTdBr6to yypa5NpyqcP825JexPYvpN1Sr7IDe+5wno0DRNK33R7i/e2ffBTAG5dl4VAVAxM40zjk jIBycSNqXjG1x1Ynj+eDJ+92xbZdgQNZnZOw0Bjruy83NFiJI7Cuqnv3+EC+IAKEsU1B KL99nDljShuW1Bw9euTbRE4f1w/MFjbdSOAU30F2BwSbCVP8vz41zAeBEbUx0k+Pu1vk SDFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=ri8tv6zY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w62-20020a638241000000b0050fb0a2622esi19773694pgd.400.2023.03.29.11.27.46; Wed, 29 Mar 2023 11:27:57 -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=@oracle.com header.s=corp-2022-7-12 header.b=ri8tv6zY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229511AbjC2S0N (ORCPT + 99 others); Wed, 29 Mar 2023 14:26:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjC2S0L (ORCPT ); Wed, 29 Mar 2023 14:26:11 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12E934697; Wed, 29 Mar 2023 11:26:11 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32TEU4Dc018538; Wed, 29 Mar 2023 18:25:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2022-7-12; bh=Lzu4UVcTLXuXtHWcBLcWf277KyG7v5zkXe3TdU4cGyA=; b=ri8tv6zYNiZbBwicSELs8GpcQaYSp8AD8GxlkbBp9lJGrLTlRnZAPe4RMNnUIzERINEe Tkp30Yi1+2cwq/wVyH0ctASEhOGjtvyvRBlNtBAyg84nViaxK9BDdglLyyEB0H0Fb5RB vDYYdSjyegtDGZo0S8V+ItNDysqFVk5eFBa7NNKU2evDYGS5fYuIY503rTxbqVUs2wqV Hufj4JbEnB1oE+jbEOpwhTHyhRiRwvbWlQ5fK/OzHneZ/aB51ufCz9r9eRGKh7ts4LSx DBkQfVZ5yS8Lams/qqFZ0hgfNZlaCnapH6FWVugyXwsAHu9UloEnUNM5CFwGhSWxlgso tw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pmq538pag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Mar 2023 18:25:47 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32THSmib010814; Wed, 29 Mar 2023 18:25:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3phqder9kp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Mar 2023 18:25:45 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32TIPQe1004473; Wed, 29 Mar 2023 18:25:45 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3phqder9hg-1; Wed, 29 Mar 2023 18:25:45 +0000 From: Anjali Kulkarni To: davem@davemloft.net Cc: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, zbr@ioremap.net, brauner@kernel.org, johannes@sipsolutions.net, ecree.xilinx@gmail.com, leon@kernel.org, keescook@chromium.org, socketcan@hartkopp.net, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, anjali.k.kulkarni@oracle.com Subject: [PATCH v3 0/7] Process connector bug fixes & enhancements Date: Wed, 29 Mar 2023 11:25:36 -0700 Message-Id: <20230329182543.1161480-1-anjali.k.kulkarni@oracle.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-29_12,2023-03-28_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303290141 X-Proofpoint-GUID: vDLi6591kRzl8g0-fnPG4XWANk8a6xDY X-Proofpoint-ORIG-GUID: vDLi6591kRzl8g0-fnPG4XWANk8a6xDY X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 From: Anjali Kulkarni In this series, we add filtering to the proc connector module. This is required to fix some bugs and also will enable the addition of event based filtering, which will improve performance for anyone interested in a subset of process events, as compared to the current approach, which is to send all event notifications. Thus, a client can register to listen for only exit or fork or a mix or all of the events. This greatly enhances performance - currently, we need to listen to all events, and there are 9 different types of events. For eg. handling 3 types of events - 8K-forks + 8K-exits + 8K-execs takes 200ms, whereas handling 2 types - 8K-forks + 8K-exits takes about 150ms, and handling just one type - 8K exits takes about 70ms. Reason why we need the above changes and also a new event type PROC_EVENT_NONZERO_EXIT, which is only sent by kernel to a listening application when any process exiting has a non-zero exit status is: Oracle DB runs on a large scale with 100000s of short lived processes, starting up and exiting quickly. A process monitoring DB daemon which tracks and cleans up after processes that have died without a proper exit needs notifications only when a process died with a non-zero exit code (which should be rare). This change will give Oracle DB substantial performance savings - it takes 50ms to scan about 8K PIDs in /proc, about 500ms for 100K PIDs. DB does this check every 3 secs, so over an hour we save 10secs for 100K PIDs. Measuring the time using pidfds for monitoring 8K process exits took 4 times longer - 200ms, as compared to 70ms using only exit notifications of proc connector. Hence, we cannot use pidfd for our use case. This kind of a new event could also be useful to other applications like Google's lmkd daemon, which needs a killed process's exit notification. This patch series is organized as follows - Patch 1 : Needed for patch 3 to work. Patch 2 : Needed for patch 3 to work. Patch 3 : Fixes some bugs in proc connector, details in the patch. Patch 4 : Test code for proc connector. Patch 5 : Adds event based filtering for performance enhancements. Patch 6 : Needed for patch 7 to work. Patch 7 : Allow non-root users access to proc connector events. v2->v3 changes: - Fix comments by Jakub Kicinski to separate netlink (patch 2) (after layering) from connector fixes (patch 3). - Minor fixes suggested by Jakub. - Add new multicast group level permissions check at netlink layer. Split this into netlink & connector layers (patches 6 & 7) v1->v2 changes: - Fix comments by Jakub Kicinski to keep layering within netlink and update kdocs. - Move non-root users access patch last in series so remaining patches can go in first. v->v1 changes: - Changed commit log in patch 4 as suggested by Christian Brauner - Changed patch 4 to make more fine grained access to non-root users - Fixed warning in cn_proc.c, Reported-by: kernel test robot - Fixed some existing warnings in cn_proc.c Anjali Kulkarni (7): netlink: Reverse the patch which removed filtering netlink: Add new netlink_release function connector/cn_proc: Add filtering to fix some bugs connector/cn_proc: Test code for proc connector connector/cn_proc: Performance improvements netlink: Add multicast group level permissions connector/cn_proc: Allow non-root users access drivers/connector/cn_proc.c | 105 +++++++++-- drivers/connector/connector.c | 22 ++- drivers/w1/w1_netlink.c | 6 +- include/linux/connector.h | 8 +- include/linux/netlink.h | 7 + include/uapi/linux/cn_proc.h | 62 +++++-- net/netlink/af_netlink.c | 56 +++++- net/netlink/af_netlink.h | 6 + samples/connector/proc_filter.c | 301 ++++++++++++++++++++++++++++++++ 9 files changed, 528 insertions(+), 45 deletions(-) create mode 100644 samples/connector/proc_filter.c -- 2.40.0