2016-03-13 07:18:56

by Geliang Tang

[permalink] [raw]
Subject: [PATCH 1/3] rbd: use KMEM_CACHE macro

Use KMEM_CACHE() instead of kmem_cache_create() to simplify the code.

Signed-off-by: Geliang Tang <[email protected]>
---
drivers/block/rbd.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 4a87678..70eba86 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5643,18 +5643,12 @@ static void rbd_sysfs_cleanup(void)
static int rbd_slab_init(void)
{
rbd_assert(!rbd_img_request_cache);
- rbd_img_request_cache = kmem_cache_create("rbd_img_request",
- sizeof (struct rbd_img_request),
- __alignof__(struct rbd_img_request),
- 0, NULL);
+ rbd_img_request_cache = KMEM_CACHE(rbd_img_request, 0);
if (!rbd_img_request_cache)
return -ENOMEM;

rbd_assert(!rbd_obj_request_cache);
- rbd_obj_request_cache = kmem_cache_create("rbd_obj_request",
- sizeof (struct rbd_obj_request),
- __alignof__(struct rbd_obj_request),
- 0, NULL);
+ rbd_obj_request_cache = KMEM_CACHE(rbd_obj_request, 0);
if (!rbd_obj_request_cache)
goto out_err;

--
2.5.0



2016-03-13 07:19:23

by Geliang Tang

[permalink] [raw]
Subject: [PATCH 3/3] libceph: use KMEM_CACHE macro

Use KMEM_CACHE() instead of kmem_cache_create() to simplify the code.

Signed-off-by: Geliang Tang <[email protected]>
---
net/ceph/messenger.c | 10 ++--------
net/ceph/osd_client.c | 5 +----
2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 9382619..32c997e 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -235,18 +235,12 @@ static struct workqueue_struct *ceph_msgr_wq;
static int ceph_msgr_slab_init(void)
{
BUG_ON(ceph_msg_cache);
- ceph_msg_cache = kmem_cache_create("ceph_msg",
- sizeof (struct ceph_msg),
- __alignof__(struct ceph_msg), 0, NULL);
-
+ ceph_msg_cache = KMEM_CACHE(ceph_msg, 0);
if (!ceph_msg_cache)
return -ENOMEM;

BUG_ON(ceph_msg_data_cache);
- ceph_msg_data_cache = kmem_cache_create("ceph_msg_data",
- sizeof (struct ceph_msg_data),
- __alignof__(struct ceph_msg_data),
- 0, NULL);
+ ceph_msg_data_cache = KMEM_CACHE(ceph_msg_data, 0);
if (ceph_msg_data_cache)
return 0;

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 5bc0537..7558855 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -2783,10 +2783,7 @@ EXPORT_SYMBOL(ceph_osdc_writepages);
int ceph_osdc_setup(void)
{
BUG_ON(ceph_osd_request_cache);
- ceph_osd_request_cache = kmem_cache_create("ceph_osd_request",
- sizeof (struct ceph_osd_request),
- __alignof__(struct ceph_osd_request),
- 0, NULL);
+ ceph_osd_request_cache = KMEM_CACHE(ceph_osd_request, 0);

return ceph_osd_request_cache ? 0 : -ENOMEM;
}
--
2.5.0


2016-03-13 07:19:14

by Geliang Tang

[permalink] [raw]
Subject: [PATCH 2/3] dlm: use KMEM_CACHE macro

Use KMEM_CACHE() instead of kmem_cache_create() to simplify the code.

Signed-off-by: Geliang Tang <[email protected]>
---
fs/dlm/memory.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c
index 7cd24bc..6baa721 100644
--- a/fs/dlm/memory.c
+++ b/fs/dlm/memory.c
@@ -21,13 +21,11 @@ static struct kmem_cache *rsb_cache;

int __init dlm_memory_init(void)
{
- lkb_cache = kmem_cache_create("dlm_lkb", sizeof(struct dlm_lkb),
- __alignof__(struct dlm_lkb), 0, NULL);
+ lkb_cache = KMEM_CACHE(dlm_lkb, 0);
if (!lkb_cache)
return -ENOMEM;

- rsb_cache = kmem_cache_create("dlm_rsb", sizeof(struct dlm_rsb),
- __alignof__(struct dlm_rsb), 0, NULL);
+ rsb_cache = KMEM_CACHE(dlm_rsb, 0);
if (!rsb_cache) {
kmem_cache_destroy(lkb_cache);
return -ENOMEM;
--
2.5.0


2016-03-22 16:55:48

by Ilya Dryomov

[permalink] [raw]
Subject: Re: [PATCH 1/3] rbd: use KMEM_CACHE macro

On Sun, Mar 13, 2016 at 8:17 AM, Geliang Tang <[email protected]> wrote:
> Use KMEM_CACHE() instead of kmem_cache_create() to simplify the code.
>
> Signed-off-by: Geliang Tang <[email protected]>
> ---
> drivers/block/rbd.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 4a87678..70eba86 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -5643,18 +5643,12 @@ static void rbd_sysfs_cleanup(void)
> static int rbd_slab_init(void)
> {
> rbd_assert(!rbd_img_request_cache);
> - rbd_img_request_cache = kmem_cache_create("rbd_img_request",
> - sizeof (struct rbd_img_request),
> - __alignof__(struct rbd_img_request),
> - 0, NULL);
> + rbd_img_request_cache = KMEM_CACHE(rbd_img_request, 0);
> if (!rbd_img_request_cache)
> return -ENOMEM;
>
> rbd_assert(!rbd_obj_request_cache);
> - rbd_obj_request_cache = kmem_cache_create("rbd_obj_request",
> - sizeof (struct rbd_obj_request),
> - __alignof__(struct rbd_obj_request),
> - 0, NULL);
> + rbd_obj_request_cache = KMEM_CACHE(rbd_obj_request, 0);
> if (!rbd_obj_request_cache)
> goto out_err;
>

Applied.

Thanks,

Ilya

2016-03-22 16:58:10

by Ilya Dryomov

[permalink] [raw]
Subject: Re: [PATCH 3/3] libceph: use KMEM_CACHE macro

On Sun, Mar 13, 2016 at 8:18 AM, Geliang Tang <[email protected]> wrote:
> Use KMEM_CACHE() instead of kmem_cache_create() to simplify the code.
>
> Signed-off-by: Geliang Tang <[email protected]>
> ---
> net/ceph/messenger.c | 10 ++--------
> net/ceph/osd_client.c | 5 +----
> 2 files changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
> index 9382619..32c997e 100644
> --- a/net/ceph/messenger.c
> +++ b/net/ceph/messenger.c
> @@ -235,18 +235,12 @@ static struct workqueue_struct *ceph_msgr_wq;
> static int ceph_msgr_slab_init(void)
> {
> BUG_ON(ceph_msg_cache);
> - ceph_msg_cache = kmem_cache_create("ceph_msg",
> - sizeof (struct ceph_msg),
> - __alignof__(struct ceph_msg), 0, NULL);
> -
> + ceph_msg_cache = KMEM_CACHE(ceph_msg, 0);
> if (!ceph_msg_cache)
> return -ENOMEM;
>
> BUG_ON(ceph_msg_data_cache);
> - ceph_msg_data_cache = kmem_cache_create("ceph_msg_data",
> - sizeof (struct ceph_msg_data),
> - __alignof__(struct ceph_msg_data),
> - 0, NULL);
> + ceph_msg_data_cache = KMEM_CACHE(ceph_msg_data, 0);
> if (ceph_msg_data_cache)
> return 0;
>
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index 5bc0537..7558855 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -2783,10 +2783,7 @@ EXPORT_SYMBOL(ceph_osdc_writepages);
> int ceph_osdc_setup(void)
> {
> BUG_ON(ceph_osd_request_cache);
> - ceph_osd_request_cache = kmem_cache_create("ceph_osd_request",
> - sizeof (struct ceph_osd_request),
> - __alignof__(struct ceph_osd_request),
> - 0, NULL);
> + ceph_osd_request_cache = KMEM_CACHE(ceph_osd_request, 0);
>
> return ceph_osd_request_cache ? 0 : -ENOMEM;
> }

Applied, with osd_client.c hunk dropped. ceph_osd_request cache
objects are not longer sizeof(struct ceph_osd_request).

Thanks,

Ilya