Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1174838pxb; Thu, 4 Feb 2021 06:51:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbjvGryQYo/4x5gJQ3Ru3MYV+oszkrBIA8ix4x5iziqBaVnFIwDdm6UNSTZfk0TAvW2f4D X-Received: by 2002:a17:906:cc56:: with SMTP id mm22mr8208916ejb.181.1612450316112; Thu, 04 Feb 2021 06:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612450316; cv=none; d=google.com; s=arc-20160816; b=U4TlUjEoOPxozz2V1nql2+miF/jcTT9iJw3/QVDSZ4TTiVXasvp5oahv3+4zkLptut ciLG/7b9B7eiwsYA6590W6AXQ6WEBkZos2pSBHOBTw1V8EKVFFdNt14rztKXOG04Vdqj phj9wWvpfwYGSO2tgGUbwonn00nPJ+U1bgB38l7tjCRy9EQFhu5JnzXEZV5Q0CkQVEjm XfYzCPoSLX7yey6Sum3h5BKr8txBJWH6PZXv/2KQyNzb9MCxRDr/y6qm2L1KdZp4Nv0l MWduZJjqHkCsKRoENE0tRzByTH3UUbcpfYjjnw6LS9ssNLYpFE91kg+a3sj+22dnmD7M v6cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7/yRcIj7Ri9v/Iuf2m4A5vPR9JhrB8gLvi7llcT4qLU=; b=lgte+Zm/Mq9moeJIuGXBc014rnXdlysjz+aZFR3Hj+XRU/J8NweMtk6P25OXrOXeE7 bUVTvq3VyGPKhj3A5rkU9NQxbGovtGKvTXKeA4oh8ES9gvYOu6JKCK8BY/ZUEUUKAQ4+ Zmx2pk7GCB6OAQCv6oBmAwYpwHlFaMPdixDeKXL4jZsuXuD/ye+7jwKIt3T/v71yImW+ ORa1nkmXEiCWZpBJn+ZAm83v/2ZOxiKDrfbVU244yXWDM5S8w5GaiyVGRYvttAOTUnul 1Xh0fyd8VJCWKzuRX05VIFBilcFcd51nSND4iIIDvVg/OtzJanHfZjEF+0cL4kJwqIeK 6Eew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KPRd1fBP; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si3241908ejb.606.2021.02.04.06.51.30; Thu, 04 Feb 2021 06:51:56 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=KPRd1fBP; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236702AbhBDOrv (ORCPT + 99 others); Thu, 4 Feb 2021 09:47:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236823AbhBDOkC (ORCPT ); Thu, 4 Feb 2021 09:40:02 -0500 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2BADC061786 for ; Thu, 4 Feb 2021 06:38:55 -0800 (PST) Received: by mail-qv1-xf36.google.com with SMTP id w11so1767927qvz.12 for ; Thu, 04 Feb 2021 06:38:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7/yRcIj7Ri9v/Iuf2m4A5vPR9JhrB8gLvi7llcT4qLU=; b=KPRd1fBPasbam1KhitLLM8BTeKPhJhT8CbnVd6mMy1jnuAM5aFdVRuYvWFnL8QoUC9 qRGmu9a+l0uhPffRqRAvv0GF9W86V71h08lwLCNMecERwm6WsiD9ciIePKfV6c7HXixV 203qSNb4U9rHQfPgNx2YLWAEf86Gk1R5atey3S/OoucymOThEt73V/EcivgMXBrXe7fK GCvXXXUBwvRY/KRDMFoygCuZP9WGJFlmom2d1ZG476Y1SOj39MWKkqw13LExaWHyMRRy g/N2+QolMJ8izsz5x0ybb27l8hgce/X4OPoyq5kmkrz1NbYFYEfTUrzDRuCxGXkixI32 dbUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7/yRcIj7Ri9v/Iuf2m4A5vPR9JhrB8gLvi7llcT4qLU=; b=gOcgmscbFd+1HAIk1y/JU9lGigcRu/aab6yiC++bL/BmxHpXwa7D5fokX7QEwfm66r RMJ3jQ9anSH/XeDrCQe3llqEEQgVZ0Y1E/YxLhw2nF9re4BEdofkr6hQTmi30Jj0vbME 5Y2VLmVn7Hm7iYRJ4WAadI4E9DaRqdT1bzT/5Sjg44rtTuETxHmEtaE189pzAbcRL+s/ oj15oGp1U8/3zsi28oT7CYveuhrJE+81cKuMjdlV0SbswFne5kgX7yT/yVc5L7jA7D3q O4P0GnimoHCPPpu++sEnTzhIINIyuu1kPKJK7Sgp0AnVYd6yl+yVp7gMh4ofPJOqhT+E NCiw== X-Gm-Message-State: AOAM530iFhomA7MWexoUW6BxOCApNxjmIGiMndA6faA20xC+Q3iMLohg LMNwgBKspnJ5Gk3N45Y6tRM4SoIP/zBD0bPqLb4= X-Received: by 2002:a0c:f7d2:: with SMTP id f18mr7615667qvo.39.1612449534837; Thu, 04 Feb 2021 06:38:54 -0800 (PST) MIME-Version: 1.0 References: <20201217170009.GA29186@192.168.3.9> <20210127111346.GB59838@balbir-desktop> <20210204102020.GA286763@balbir-desktop> In-Reply-To: <20210204102020.GA286763@balbir-desktop> From: Weiping Zhang Date: Thu, 4 Feb 2021 22:37:20 +0800 Message-ID: Subject: Re: [RFC PATCH v2] taskstats: add /proc/taskstats to fetch pid/tgid status To: Balbir Singh Cc: sblbir@amazon.com, davem@davemloft.net, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 4, 2021 at 6:20 PM Balbir Singh wrote: > > On Sun, Jan 31, 2021 at 05:16:47PM +0800, Weiping Zhang wrote: > > On Wed, Jan 27, 2021 at 7:13 PM Balbir Singh wrote: > > > > > > On Fri, Jan 22, 2021 at 10:07:50PM +0800, Weiping Zhang wrote: > > > > Hello Balbir Singh, > > > > > > > > Could you help review this patch, thanks > > > > > > > > On Mon, Dec 28, 2020 at 10:10 PM Weiping Zhang wrote: > > > > > > > > > > Hi David, > > > > > > > > > > Could you help review this patch ? > > > > > > > > > > thanks > > > > > > > > > > On Fri, Dec 18, 2020 at 1:24 AM Weiping Zhang > > > > > wrote: > > > > > > > > > > > > If a program needs monitor lots of process's status, it needs two > > > > > > syscalls for every process. The first one is telling kernel which > > > > > > pid/tgid should be monitored by send a command(write socket) to kernel. > > > > > > The second one is read the statistics by read socket. This patch add > > > > > > a new interface /proc/taskstats to reduce two syscalls to one ioctl. > > > > > > The user just set the target pid/tgid to the struct taskstats.ac_pid, > > > > > > then kernel will collect statistics for that pid/tgid. > > > > > > > > > > > > Signed-off-by: Weiping Zhang > > > > > > Could you elaborate on the overhead your seeing for the syscalls? I am not > > > in favour of adding new IOCTL's. > > > > > > Balbir Singh. > > > > Hello Balbir Singh, > > > > Sorry for late reply, > > > > I do a performance test between netlink mode and ioctl mode, > > monitor 1000 and 10000 sleep processes, > > the netlink mode cost more time than ioctl mode, that is to say > > ioctl mode can save some cpu resource and has a quickly reponse > > especially when monitor lot of process. > > > > proccess-count netlink ioctl > > --------------------------------------------- > > 1000 0.004446851 0.001553733 > > 10000 0.047024986 0.023290664 > > > > you can get the test demo code from the following link > > https://github.com/dublio/tools/tree/master/c/taskstat > > > > Let me try it out, I am opposed to adding the new IOCTL interface > you propose. How frequently do you monitor this data and how much > time in spent in making decision on the data? I presume the data > mentioned is the cost per call in seconds? > This program just read every process's taskstats from kernel and do not any extra data calculation, that is to say it just test the time spend on these syscalls. It read data every 1 second, the output is delta time spend to read all 1000 or 10000 processes's taskstat. t1 = clock_gettime(); for_each_pid /* 1000 or 10000 */ read_pid_taskstat t2 = clock_gettime(); delta = t2 - t1. > > proccess-count netlink ioctl > > --------------------------------------------- > > 1000 0.004446851 0.001553733 > > 10000 0.047024986 0.023290664 Since netlink mode needs two syscall and ioctl mode needs one syscall the test result shows netlink cost double time compare to ioctl. So I want to add this interface to reduce the time cost by syscall. You can get the test script from: https://github.com/dublio/tools/tree/master/c/taskstat#test-the-performance-between-netlink-and-ioctl-mode Thanks > Balbir Singh >