Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp737370pxb; Wed, 20 Jan 2021 20:38:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyq24gSNjBm8fKkg1v3lNFcU0d4u52cztNijb92C5SvrHgQAL2n52e63lItySkqcQZj9jB5 X-Received: by 2002:a17:906:653:: with SMTP id t19mr8074536ejb.44.1611203936397; Wed, 20 Jan 2021 20:38:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611203936; cv=none; d=google.com; s=arc-20160816; b=gfRakYW6FqZoqyQt5PtdnU8EERAMGEMFt1GP8BPoPs/e/WVdrpzEnzm0CdJVvu4r5t e9irP2NR6umZsAorVwLQRDRUwPYIN8+plcNsTajj/eaOQgvgTdiMxDP1e9lkEWhZjgKq bGTceFlDUIcwZXIqkw5UwZJlRXurZwC0utRJZ10/oGjdD0eKgsa/O3YYih4yHKrjx7Q8 15FJoTOrbn5W2VHsO0EZPwqjI6rVa1duipuQ5fQK9dEDVRI3gd0MOrJ3oteUaf+SNb5F 67lbN+BfgYeBg+MgDqfBafbgUTSSja+AI+EzAyx/P8S8s+MX2iOt+2zLxA/g5Mjxlwey V6PQ== 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=8ovp6uu8GZU/72kGxqTfPjkW2rvPcfWPOhm7bRXegKI=; b=x6YZ087/T5YjTjDBVfbyLZpegHq8/y625DHk9/hvSSxZzpzMwT9EyWNjcRQDXOCnj4 cVe+MHWskQgaH45isrLmpZmh6Q8GbS/2o18V09aIH826VSlNzQpkrz9zzZ3Wyzipcotw 6jIDcXCC+YSVxrkCx3cJgKWLn885BLF6u8mnbbk6z/C/205opeN/23ToPAgQnFfVc6ZA Aa7mNqdn9vZO1qcKhIOnYX2/ttHRUNp+FQkwv+WpguiH2heIdTF8d7e30WyeQMwgdFXf G2JlcopP9BOPv3NPNMoflRt5DKP922a2bMEQ4S5WDSAleirvtaR33fjW3Y9cpPp2YJ0N 8L5A== 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 s12si1675694edd.70.2021.01.20.20.38.33; Wed, 20 Jan 2021 20:38: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; 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 S1727852AbhAUEfZ (ORCPT + 99 others); Wed, 20 Jan 2021 23:35:25 -0500 Received: from mail-lf1-f43.google.com ([209.85.167.43]:33828 "EHLO mail-lf1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728563AbhAUEeb (ORCPT ); Wed, 20 Jan 2021 23:34:31 -0500 Received: by mail-lf1-f43.google.com with SMTP id o19so730535lfo.1 for ; Wed, 20 Jan 2021 20:34:15 -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=8ovp6uu8GZU/72kGxqTfPjkW2rvPcfWPOhm7bRXegKI=; b=KCgabE9AxNqPeBXT8gnPfFlDg43VDtcwUE0zbH6gdGHpD878gx058ylXjh/L7ZVAR5 gj0RzmNX+P3eVeBcOa2f74ugn8TrdkAjTe/4MZj5A3z+D9tgrOueLgKvsnLNtLnAbja+ DnG0Jv15EcY6XnJStyvvl50UY1meL1WMiMeH17EUYG4naNbjCoggJtlWPIqqCdLjXXtx GxO+3REAqYETKdgZCuYUFzWqhMd1n4fNAaibqCzOmHxhAWyY9ovcrPm9CY0Mns8wy6M5 +8zel3rzD/vla58TKHEXPYFXvUbZCZBxKnWVb6tBOtyUEwLNYe6cXo553mv/ZsCKw5cL waRQ== X-Gm-Message-State: AOAM5316kAyv4IoCZxG9gmBIeijtlc5i20hOB3/aI0LcTbpfgiR0Jluk sFuN7mH8ApPMiXnYACgIcO1Rxlmm2ybbgKBEDrU= X-Received: by 2002:a19:8584:: with SMTP id h126mr5709146lfd.152.1611203629557; Wed, 20 Jan 2021 20:33:49 -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: Thu, 21 Jan 2021 13:33:37 +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 Hi Arnaldo, Can you share your thoughts on this? On Fri, Jan 8, 2021 at 2:51 PM Namhyung Kim wrote: > > 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