From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx138.postini.com [74.125.245.138]) by kanga.kvack.org (Postfix) with SMTP id 6AC306B005D for ; Tue, 19 Jun 2012 20:29:29 -0400 (EDT) MIME-Version: 1.0 Message-ID: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> Date: Tue, 19 Jun 2012 17:29:03 -0700 (PDT) From: Dan Magenheimer Subject: help converting zcache from sysfs to debugfs? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org Cc: Seth Jennings , Nitin Gupta , Konrad Wilk , Sasha Levin Zcache (in staging) has a large number of read-only counters that are primarily of interest to developers. These counters are currently visible from sysfs. However sysfs is not really appropriate and zcache will need to switch to debugfs before it can be promoted out of staging. For some of the counters, it is critical that they remain accurate so an atomic_t must be used. But AFAICT there is no way for debugfs to work with atomic_t. Is that correct? Or am I missing something? Assuming it is correct, I have a workaround but it is ugly: static unsigned long counterX; static atomic_t atomic_counterX; =09counterX =3D atomic_*_return(atomic_counterX) and use atomic_counter in normal code and counter for debugfs. This works but requires each counter to be stored twice AND makes the code look ugly. Is there a better way? I can probably bury the ugliness in macros but that doesn't solve the duplicate storage. (Though since there are only about a dozen, maybe it doesn't matter?) Thanks, Dan -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx156.postini.com [74.125.245.156]) by kanga.kvack.org (Postfix) with SMTP id 44E826B0081 for ; Wed, 20 Jun 2012 07:03:04 -0400 (EDT) Received: by wgbdt14 with SMTP id dt14so6808045wgb.26 for ; Wed, 20 Jun 2012 04:03:02 -0700 (PDT) MIME-Version: 1.0 Reply-To: konrad@darnok.org In-Reply-To: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> References: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> Date: Wed, 20 Jun 2012 07:03:02 -0400 Message-ID: Subject: Re: help converting zcache from sysfs to debugfs? From: Konrad Rzeszutek Wilk Content-Type: multipart/alternative; boundary=f46d04428d2abb3e0a04c2e5575f Sender: owner-linux-mm@kvack.org List-ID: To: Dan Magenheimer Cc: Nitin Gupta , linux-mm@kvack.org, Seth Jennings , Sasha Levin , Konrad Wilk --f46d04428d2abb3e0a04c2e5575f Content-Type: text/plain; charset=ISO-8859-1 On Jun 19, 2012 8:30 PM, "Dan Magenheimer" wrote: > > Zcache (in staging) has a large number of read-only counters that > are primarily of interest to developers. These counters are currently > visible from sysfs. However sysfs is not really appropriate and > zcache will need to switch to debugfs before it can be promoted > out of staging. > > For some of the counters, it is critical that they remain accurate so > an atomic_t must be used. But AFAICT there is no way for debugfs > to work with atomic_t. Which ones must be atomic? Do they really need to be atomic if they are for diagnostics/developers? > > Is that correct? Or am I missing something? > > Assuming it is correct, I have a workaround but it is ugly: > > static unsigned long counterX; > static atomic_t atomic_counterX; > > counterX = atomic_*_return(atomic_counterX) > > and use atomic_counter in normal code and counter for debugfs. > > This works but requires each counter to be stored twice AND > makes the code look ugly. But only for those counters that truly must be atomic. > > Is there a better way? I can probably bury the ugliness in > macros but that doesn't solve the duplicate storage. (Though > since there are only about a dozen, maybe it doesn't matter?) A dozen that _MUST_ be atomic? > > Thanks, > Dan > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: --f46d04428d2abb3e0a04c2e5575f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On Jun 19, 2012 8:30 PM, "Dan Magenheimer" <
dan.magenheimer@oracle.com> wrote:
>
> Zcache (in staging) has a large number of read-only counters that
> are primarily of interest to developers. =A0These counters are current= ly
> visible from sysfs. =A0However sysfs is not really appropriate and
> zcache will need to switch to debugfs before it can be promoted
> out of staging.
>
> For some of the counters, it is critical that they remain accurate so<= br> > an atomic_t must be used. =A0But AFAICT there is no way for debugfs > to work with atomic_t.

Which ones must be atomic? Do they really need to be atomic if they are = for diagnostics/developers?
>
> Is that correct? =A0Or am I missing something?
>
> Assuming it is correct, I have a workaround but it is ugly:
>
> static unsigned long counterX;
> static atomic_t atomic_counterX;
>
> =A0 =A0 =A0 =A0counterX =3D atomic_*_return(atomic_counterX)
>
> and use atomic_counter in normal code and counter for debugfs.
>
> This works but requires each counter to be stored twice AND
> makes the code look ugly.

But only for those counters that truly must be atomic.
>
> Is there a better way? =A0I can probably bury the ugliness in
> macros but that doesn't solve the duplicate storage. =A0(Though > since there are only about a dozen, maybe it doesn't matter?)

<= p>A dozen that _MUST_ be atomic?

>
> Thanks,
> Dan
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in<= br> > the body to
m= ajordomo@kvack.org. =A0For more info on Linux MM,
> see: http://www= .linux-mm.org/ .
> Don't email: <a href
>

--f46d04428d2abb3e0a04c2e5575f-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx169.postini.com [74.125.245.169]) by kanga.kvack.org (Postfix) with SMTP id 2AB5F6B0062 for ; Wed, 20 Jun 2012 10:29:01 -0400 (EDT) Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Jun 2012 08:28:59 -0600 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 4D75EC90093 for ; Wed, 20 Jun 2012 10:20:37 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5KEKaUA145050 for ; Wed, 20 Jun 2012 10:20:36 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5KEKWAd017938 for ; Wed, 20 Jun 2012 11:20:32 -0300 Message-ID: <4FE1DC24.6020508@linux.vnet.ibm.com> Date: Wed, 20 Jun 2012 09:20:20 -0500 From: Seth Jennings MIME-Version: 1.0 Subject: Re: help converting zcache from sysfs to debugfs? References: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> In-Reply-To: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Dan Magenheimer Cc: linux-mm@kvack.org, Nitin Gupta , Konrad Wilk , Sasha Levin On 06/19/2012 07:29 PM, Dan Magenheimer wrote: > Zcache (in staging) has a large number of read-only counters that > are primarily of interest to developers. These counters are currently > visible from sysfs. However sysfs is not really appropriate and > zcache will need to switch to debugfs before it can be promoted > out of staging. > > For some of the counters, it is critical that they remain accurate so > an atomic_t must be used. But AFAICT there is no way for debugfs > to work with atomic_t. Yes, there doesn't seem to be an existing interface. You could add support for it to fs/debugfs/file.c. It doesn't look too complicated. -- Seth -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx123.postini.com [74.125.245.123]) by kanga.kvack.org (Postfix) with SMTP id BE52A6B006C for ; Wed, 20 Jun 2012 10:44:51 -0400 (EDT) Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Jun 2012 08:44:50 -0600 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id A4F05C90198 for ; Wed, 20 Jun 2012 10:36:18 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5KEaJip187522 for ; Wed, 20 Jun 2012 10:36:19 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5KEaHNu003944 for ; Wed, 20 Jun 2012 10:36:18 -0400 Message-ID: <4FE1DFDC.1010105@linux.vnet.ibm.com> Date: Wed, 20 Jun 2012 09:36:12 -0500 From: Seth Jennings MIME-Version: 1.0 Subject: Re: help converting zcache from sysfs to debugfs? References: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> In-Reply-To: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Dan Magenheimer Cc: linux-mm@kvack.org, Nitin Gupta , Konrad Wilk , Sasha Levin Something like this (untested): diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 2340f69..652b882 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -21,6 +21,7 @@ #include #include #include +#include static ssize_t default_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos) @@ -403,6 +404,45 @@ struct dentry *debugfs_create_size_t(const char *name, umode_t mode, } EXPORT_SYMBOL_GPL(debugfs_create_size_t); +static int debugfs_atomic_t_set(void *data, u64 val) +{ + atomic_set((atomic_t *)data, val); + return 0; +} +static int debugfs_atomic_t_get(void *data, u64 *val) +{ + *val = atomic_read((atomic_t *)data); + return 0; +} +DEFINE_SIMPLE_ATTRIBUTE(fops_atomic_t, debugfs_atomic_t_get, + debugfs_atomic_t_set, "%llu\n"); +DEFINE_SIMPLE_ATTRIBUTE(fops_atomic_t_ro, debugfs_atomic_t_get, NULL, "%llu\n"); +DEFINE_SIMPLE_ATTRIBUTE(fops_atomic_t_wo, NULL, debugfs_atomic_t_set, "%llu\n"); + +/** + * debugfs_create_atomic_t - create a debugfs file that is used to read and + * write an atomic_t value + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this parameter is %NULL, then the + * file will be created in the root of the debugfs filesystem. + * @value: a pointer to the variable that the file should read to and write + * from. + */ +struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode, + struct dentry *parent, atomic_t *value) +{ + /* if there are no write bits set, make read only */ + if (!(mode & S_IWUGO)) + return debugfs_create_file(name, mode, parent, value, &fops_atomic_t_ro); + /* if there are no read bits set, make write only */ + if (!(mode & S_IRUGO)) + return debugfs_create_file(name, mode, parent, value, &fops_atomic_t_wo); + + return debugfs_create_file(name, mode, parent, value, &fops_atomic_t); +} +EXPORT_SYMBOL_GPL(debugfs_create_atomic_t); static ssize_t read_file_bool(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 66c434f..51fea70 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -79,6 +79,8 @@ struct dentry *debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, u64 *value); struct dentry *debugfs_create_size_t(const char *name, umode_t mode, struct dentry *parent, size_t *value); +struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode, + struct dentry *parent, atomic_t *value); struct dentry *debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, u32 *value); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx139.postini.com [74.125.245.139]) by kanga.kvack.org (Postfix) with SMTP id E48F16B0070 for ; Wed, 20 Jun 2012 11:25:17 -0400 (EDT) MIME-Version: 1.0 Message-ID: <71fe129f-25c2-471b-b3f1-42706ba31048@default> Date: Wed, 20 Jun 2012 08:24:04 -0700 (PDT) From: Dan Magenheimer Subject: RE: help converting zcache from sysfs to debugfs? References: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: konrad@darnok.org Cc: Nitin Gupta , linux-mm@kvack.org, Seth Jennings , Sasha Levin , Konrad Wilk > From: Konrad Rzeszutek Wilk [mailto:konrad@darnok.org] > Subject: Re: help converting zcache from sysfs to debugfs? >=20 > On Jun 19, 2012 8:30 PM, "Dan Magenheimer" w= rote: > > > > Zcache (in staging) has a large number of read-only counters that > > are primarily of interest to developers. These counters are currently > > visible from sysfs. However sysfs is not really appropriate and > > zcache will need to switch to debugfs before it can be promoted > > out of staging. > > > > For some of the counters, it is critical that they remain accurate so > > an atomic_t must be used. But AFAICT there is no way for debugfs > > to work with atomic_t. >=20 > Which ones must be atomic? Do they really need to be atomic if they are f= or diagnostics/developers? > : > A dozen that _MUST_ be atomic? Hi Konrad -- On second look, there are only eight. They are unsigned, go up and down, and the code needs to know if/when they are zero (or BUG if they go below zero). When viewed by a developer (or very savvy administrator), they can be viewed directly or feed into analysis tools that would likely get very confused by "huge" ("negative unsigned") values. Recently, Seth changed one zcache counter from unsigned to atomic_t for this reason. Thanks, Dan -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx152.postini.com [74.125.245.152]) by kanga.kvack.org (Postfix) with SMTP id 7F06F6B0070 for ; Wed, 20 Jun 2012 11:31:00 -0400 (EDT) MIME-Version: 1.0 Message-ID: <83884ff2-1a06-4d9c-a7eb-c53ab0cbb6b1@default> Date: Wed, 20 Jun 2012 08:30:35 -0700 (PDT) From: Dan Magenheimer Subject: RE: help converting zcache from sysfs to debugfs? References: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> <4FE1DFDC.1010105@linux.vnet.ibm.com> In-Reply-To: <4FE1DFDC.1010105@linux.vnet.ibm.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: Seth Jennings Cc: linux-mm@kvack.org, Nitin Gupta , Konrad Wilk , Sasha Levin > From: Seth Jennings [mailto:sjenning@linux.vnet.ibm.com] > Subject: Re: help converting zcache from sysfs to debugfs? >=20 > Something like this (untested): Nice! I also need a set for atomic_long_t. But forgive me if I nearly have a heart attack as I contemplate another chicken-and-egg scenario trying to get debugfs-support-for-atomics upstream before zcache code that depends on it. Maybe I'm a leetle bit over-sensitized to dependencies... or maybe not enough ;-) Anyway, I will probably use the ugly code and add a comment that says the code can be made cleaner when debugfs supports atomics. Thanks! Dan -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx180.postini.com [74.125.245.180]) by kanga.kvack.org (Postfix) with SMTP id 863376B0070 for ; Wed, 20 Jun 2012 11:41:22 -0400 (EDT) Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Jun 2012 09:41:21 -0600 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 20624C900AE for ; Wed, 20 Jun 2012 11:41:02 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5KFf3h5184584 for ; Wed, 20 Jun 2012 11:41:03 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5KFf2lP031851 for ; Wed, 20 Jun 2012 12:41:02 -0300 Message-ID: <4FE1EF0B.2050109@linux.vnet.ibm.com> Date: Wed, 20 Jun 2012 10:40:59 -0500 From: Seth Jennings MIME-Version: 1.0 Subject: Re: help converting zcache from sysfs to debugfs? References: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> <4FE1DFDC.1010105@linux.vnet.ibm.com> <83884ff2-1a06-4d9c-a7eb-c53ab0cbb6b1@default> In-Reply-To: <83884ff2-1a06-4d9c-a7eb-c53ab0cbb6b1@default> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Dan Magenheimer Cc: linux-mm@kvack.org, Nitin Gupta , Konrad Wilk , Sasha Levin On 06/20/2012 10:30 AM, Dan Magenheimer wrote: > But forgive me if I nearly have a heart attack as I > contemplate another chicken-and-egg scenario trying > to get debugfs-support-for-atomics upstream before > zcache code that depends on it. I don't think this is the same situation as most of our other chicken and egg situations. This is a very generic addition to debugfs (i.e. someone anyone can use, not just zcache). Especially as more people use debugfs or convert some of their sysfs to debufs. In all honesty, I'm surprised it hasn't been added sooner. -- Seth -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx133.postini.com [74.125.245.133]) by kanga.kvack.org (Postfix) with SMTP id 7ACD66B005A for ; Wed, 20 Jun 2012 13:04:00 -0400 (EDT) Date: Wed, 20 Jun 2012 12:56:10 -0400 From: Konrad Rzeszutek Wilk Subject: Re: help converting zcache from sysfs to debugfs? Message-ID: <20120620165610.GA2991@phenom.dumpdata.com> References: <6b8ff49a-a5aa-4b9b-9425-c9bc7df35a34@default> <4FE1DFDC.1010105@linux.vnet.ibm.com> <83884ff2-1a06-4d9c-a7eb-c53ab0cbb6b1@default> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <83884ff2-1a06-4d9c-a7eb-c53ab0cbb6b1@default> Sender: owner-linux-mm@kvack.org List-ID: To: Dan Magenheimer Cc: Seth Jennings , linux-mm@kvack.org, Nitin Gupta , Sasha Levin On Wed, Jun 20, 2012 at 08:30:35AM -0700, Dan Magenheimer wrote: > > From: Seth Jennings [mailto:sjenning@linux.vnet.ibm.com] > > Subject: Re: help converting zcache from sysfs to debugfs? > > > > Something like this (untested): > > Nice! I also need a set for atomic_long_t. > > But forgive me if I nearly have a heart attack as I > contemplate another chicken-and-egg scenario trying > to get debugfs-support-for-atomics upstream before > zcache code that depends on it. > > Maybe I'm a leetle bit over-sensitized to dependencies... > or maybe not enough ;-) I wouldn't that much. Especially as Greg KH is the maintainer of debugfs. > > Anyway, I will probably use the ugly code and add a > comment that says the code can be made cleaner when > debugfs supports atomics. > > Thanks! > Dan > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org