Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp66495pxb; Thu, 7 Jan 2021 21:54:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdlaqKi6bHZ7oscUDeDfK9PJm2cLd0zUXXqa4MA5hi0kWrUw/B98kdVwz4s8kFHn95ooFu X-Received: by 2002:a17:906:447:: with SMTP id e7mr1606573eja.172.1610085278465; Thu, 07 Jan 2021 21:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610085278; cv=none; d=google.com; s=arc-20160816; b=Fdw0TXVmZUSc+3mux9eCIkS0AvAlFHERIABTVubYMcJX2cvKwP5n5c0kFaOVy5CCAe K4+fOFeZknMwFw9VxbpY/gRgCl/7We/ktbifWY/xf7Pky7LpArQ05/xGVgFZ2wT/isW8 Qve2QxjStZFHEdSZnsJNwIq4x225mJGTFvCPp/tQDCpMAqn10PImHwDd5DYbULuJFHYL tgliF3p/1jeTez+PgJ/7cRHgEntiI5KGNeF4CFei3O49G3SEB18gZ3U0FkF8RcGOWpgb 6eCjHDOH4YG+qTw7wf8tleBZAxA1/DgC5x8I4A0YKhX7wrztNQE0N0NZzykkR0DZ1uHR +ouw== 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; bh=T6uUflP+A07+vXTj9Bxxy+BapRrAweXSFEy3fWBrl1o=; b=BK3IkPVu/FmXFIqX2aOYfXRL9nvjQZ35xEk3EWe3XwfC7E3G+JMezV1ibtJ7PcadXs EWWUF9cVPwb5T/VKYTWYMcTx0A1062hOTRXdRHTELAO8QGSybg3Lf9oCNZeqX3gL27KL JJr4t49V1ANIAU1JZ3KI32oWT/LfHRFM2HX1rOXDw93ghc1me0c/n7T0vNVszNhVfY7Y ODQwbwfg5Hwg53wDx7qRB6GEKGh2wAIbSxVn+lIglUrAR8N9FvCEIKgHQRkD6/xTxK7d EeuLwS3V4hanhHUuiRHFBvT3fchrCPjfTn0/tPN9caqvBRIo3I//ZBkjVt17N0RbNQok 2QyA== ARC-Authentication-Results: i=1; mx.google.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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hc30si3068412ejc.139.2021.01.07.21.54.14; Thu, 07 Jan 2021 21:54:38 -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; 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 S1727554AbhAHFwj (ORCPT + 99 others); Fri, 8 Jan 2021 00:52:39 -0500 Received: from mail-lf1-f42.google.com ([209.85.167.42]:43125 "EHLO mail-lf1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725791AbhAHFwi (ORCPT ); Fri, 8 Jan 2021 00:52:38 -0500 Received: by mail-lf1-f42.google.com with SMTP id 23so20235438lfg.10 for ; Thu, 07 Jan 2021 21:52:21 -0800 (PST) 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=T6uUflP+A07+vXTj9Bxxy+BapRrAweXSFEy3fWBrl1o=; b=C1gW4SoAqa1x+OYlHWiOtgwyUO96YIsjY69kkDlj5Ypiu5LHj9S5FllBOh4RvMR12F 4LQe/yvKLfOfIszOuhVLuWqy+i7AvLxOdfpBMP1GEz5krPCTZXMVkKDivZYrrs9Fp/GU 9NiRv1on14vlCjSlkou4Yj9KMYTA0YIVvDTrF4d+H+XXuN51cHawXbOvNWaTlrEBVHnT kvnf45Itn+hzJhi1fzSmgqEsHF5s3mJ0QhSC6ASeIOmhWjzwfUd5Agkvm4BABcSFHYvP IRGN9OkAzu+Fju6bYpKch7jtJGzixFWp3jUZeBDRPTnHhekYvhtxYtqDLQ8lTZYd7rca ACYA== X-Gm-Message-State: AOAM5336q93cw8a6MIwO24yJIy2YJ1ED6/MU0zUALM97GEJtv6bKdHZz 1pSEQj4qbfR7vHQlkOi+j3WJrihtuo/lOs/IJCM= X-Received: by 2002:a19:23cf:: with SMTP id j198mr904831lfj.509.1610085116161; Thu, 07 Jan 2021 21:51:56 -0800 (PST) MIME-Version: 1.0 References: <20201216090556.813996-1-namhyung@kernel.org> <20201216090556.813996-3-namhyung@kernel.org> <20201229115158.GH521329@kernel.org> In-Reply-To: From: Namhyung Kim Date: Fri, 8 Jan 2021 14:51:44 +0900 Message-ID: Subject: Re: [PATCH 3/3] tools/lib/fs: Cache cgroupfs mount point To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Ingo Molnar , Peter Zijlstra , Mark Rutland , Alexander Shishkin , LKML , Stephane Eranian , Ian Rogers , Andi Kleen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.). Thoughts? Thanks, Namhyung