Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6446905pxb; Wed, 17 Feb 2021 05:01:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJz474Af3D7BMCOHsvVgdW156CYGnNb9qs1UF3FnGYSV5CO73vHXuAbTxGFHS6yF25VoUY8e X-Received: by 2002:a17:906:f90f:: with SMTP id lc15mr16826977ejb.367.1613566883399; Wed, 17 Feb 2021 05:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613566883; cv=none; d=google.com; s=arc-20160816; b=n491B8vTbTOszvo5wAzekXWfDLWjsg6ngFEAw0Yx0RNmaWENKGgSRlWJ7d8s7pMygu x1MqF/vkSkJFSe29DvmPcHHnElmzaf2uNF1rYAq4Mn9qFUmYXqmpWzjzCK2WaPawUYCH 9EIb2jKh2WIEoTSBXBquKeM6ifS92Z6wG/Z0bK6eqWYtkM7gDdYiCuUqsp8G7Q750EnN Hl5fZRsoR2S9p+opsbTK6ea4fVhloqjL2MlIJdRwtKSGTqEJpGzgCQyIndQL6v6sbCrN Oes4AnDDhcTc7RXgZaaAXPe4DVFpTelXoMGwnupgShKqkhTF37ylIZZOk21sBWv/fovJ 42bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FPGlUnezCQ1ngkD7ZjNfYisXwTh+WY6/B9toY8GpK7s=; b=CjzKWfOYI/3HFsrg7jrlUVCSefv23ChfI+SEmwmtCkHuT09/1GqHWq4a9LrxcZPU5B oTub6DC4N98t6fcUv8MWEMaJ3cusJPt1wDcdjcaBd/twjk0nhvgQLQUjImLKF6Bo4N3R dw2DWEUzLMKoq3s+bGubE1UISnT4PjjsjmsK8wgx6TYT5m+Ty5tpYgeljcWKekTtHz41 Xf4I0WBgAppzv0TdoYSD+8w1GApwFk1WZruH0jW4JgeDzXCPX36r76mYfOIshjF91/IU RhHNwvmk2HkDEYmoxRpQID5z1Tg4T5pY9IhYUl4a/zoZn+Qdft3yPOyLfOU39HD9EVP8 URxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O1Yb0vfx; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e20si1437703eje.569.2021.02.17.05.00.58; Wed, 17 Feb 2021 05:01:23 -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=@kernel.org header.s=k20201202 header.b=O1Yb0vfx; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232220AbhBQM7O (ORCPT + 99 others); Wed, 17 Feb 2021 07:59:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:56490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231709AbhBQM7L (ORCPT ); Wed, 17 Feb 2021 07:59:11 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id EE01D64E4A; Wed, 17 Feb 2021 12:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613566710; bh=LuuTZFC1X9pim/XLsOBXERDNf+hidyPvmXjt6nSvnLI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=O1Yb0vfxWPHRCJFBuuIBDynYRiPc+oDKTR8hHnIgK2ZeqslARNnJ5F0DbGPomS0RC CQIjk3IgYwiv3WmMIVOFCRLA1bZ41OChTznf7bmaIvv/+i/+zLPT76F7KXo+d22ofg 7sqW0OuxFdWEnIOYZrhYhsxjdO4sl0JefWnP4QAb3M+V8NPboDfpuNr5MleI+3v9r/ dCtIKa4BHOrzxXKqrRkIQnqKwjH/MdatZle9xqzVxdmAEdACsxpIWPm95Ux9DZARcA 5sEgxk62lQt9X9tyO9gF3CQ4Pu7s93pLLg16FsXPRgBnspSfY3s0EkGehDhDxlnAMt vS8nzB3I3O0LQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id D2D6C40CD9; Wed, 17 Feb 2021 09:58:27 -0300 (-03) Date: Wed, 17 Feb 2021 09:58:27 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Jiri Olsa , Ingo Molnar , Peter Zijlstra , Mark Rutland , Alexander Shishkin , LKML , Stephane Eranian , Ian Rogers , Andi Kleen Subject: Re: [PATCH 3/3] tools/lib/fs: Cache cgroupfs mount point Message-ID: References: <20201216090556.813996-1-namhyung@kernel.org> <20201216090556.813996-3-namhyung@kernel.org> <20201229115158.GH521329@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Jan 08, 2021 at 02:51:44PM +0900, Namhyung Kim escreveu: > On Wed, Jan 6, 2021 at 10:33 AM Namhyung Kim wrote: > > > > Hi Arnaldo, > > > > On Tue, Dec 29, 2020 at 8:51 PM Arnaldo Carvalho de Melo > > wrote: > > > > > > Em Wed, Dec 16, 2020 at 06:05:56PM +0900, Namhyung Kim escreveu: > > > > Currently it parses the /proc file everytime it opens a file in the > > > > cgroupfs. Save the last result to avoid it (assuming it won't be > > > > changed between the accesses). > > > > > > Which is the most likely case, but can't we use something like inotify > > > to detect that and bail out or warn the user? > > > > Hmm.. looks doable. Will check. > > So I've played with inotify a little bit, and it seems it needs to monitor > changes on the file or the directory. I didn't get any notification from > the /proc/mounts file even if I did some mount/umount. > > Instead, I could get IN_UNMOUNT when the cgroup filesystem was > unmounted. But for the monitoring, we need to do one of a) select-like > syscall to wait for the events, b) signal-driven IO notification or c) read > the inotify file with non-block mode everytime. > > In a library code, I don't think we can do a) or b) since it can affect > user program behaviors. Then we should go with c) but I think > it's opposite to the purpose of this patch. :) > > As you said, I think mostly we don't care as the accesses will happen > in a short period of time. But if you really care, maybe for the upcoming > perf daemon changes, I think we can add an API to invalidate the cache > or internal time-based invalidation logic (like remove it after 10 sec.). Ok, we can have something in 'perf daemon' to periodically invalidate this, maybe do a poor man inotify and when asking for the cgroup mountpoint, check some characteristic of that file that changes when it is modified, or plain use a timestamp and have some threshold. - Arnaldo > Thoughts? > > Thanks, > Namhyung -- - Arnaldo