From patchwork Wed Oct 25 08:53:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 10026057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0031B6032C for ; Wed, 25 Oct 2017 08:53:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4A5D28B20 for ; Wed, 25 Oct 2017 08:53:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8FB128B2B; Wed, 25 Oct 2017 08:53:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 163B428B20 for ; Wed, 25 Oct 2017 08:53:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932350AbdJYIxO (ORCPT ); Wed, 25 Oct 2017 04:53:14 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:45723 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932339AbdJYIxI (ORCPT ); Wed, 25 Oct 2017 04:53:08 -0400 Received: by mail-wm0-f67.google.com with SMTP id q124so402327wmb.0 for ; Wed, 25 Oct 2017 01:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=dz3QgtNwGKyThdeEJkUx2AkYbd0CX9hDHWfokmu2SzY=; b=ECrHJB/iXgciacpsU1x3A6Gw2KCL7QpRw3EbXAWx74RU0C5GgC8xFMPYRfif4HzJpe P+a7CYyuQVuL3W+WaFyq8YeyjkjNM5g03ixvmiqUe2t9LOf7bFuB75hJhMQbjuYEjxUq HPB8uQvY/zBfDHTH7ja3bgOzQkaL8vZ9XnWca/96RQ7I6WWjIEGHVuUGuWI7FIE5jRyA LN65qKo2zalTF5WQouMP6L0K059oPFPsBsmCdvXavqOU3GmyMbZdsDzmDR+KqyzuRnHq 6CPpZhU6/f+X6WvKGLoBsEi0n+dfTh9263QRq6jKk/izopesySt+vPEU811EnuTWK9fv V/aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=dz3QgtNwGKyThdeEJkUx2AkYbd0CX9hDHWfokmu2SzY=; b=PbqCT2UDaOlliEETd7Vx+/IL+Q1efYmIEDgAzGBx0ugyrcTL0PUVxi8LJs0vlFJar5 B5CgCMI8ih9uY6Lw7/7AKK0d6YFM9eHmo3cf0GW+1kZSFLuk+7PlMUGcBo9qOW/FTOjc UW7VA5WnU8yhZ9LOmWf1J7qTdDOWPA5Mlb444M+zMZtBS0/hsXnMRvIZ32nGKAVLbxGw isAqQHooAilOfepGlUDOV04o/mjtFtrDmfJvHGltWcrfZl2bwKNZskmQqDazcNGpyRlF fgKsdnW8G2G+jI2Hd5pW0THOumdyF3uOerB7HgTUACQrYwApZedGF/aaCHUklMwzKapV WH6A== X-Gm-Message-State: AMCzsaVZq9nZxH1mcsEneNXH0KRBaes1OfZPKVcsl2eBAGSTr4Uehc9B khXtPodWruStI5wAoYCbLhY+fw== X-Google-Smtp-Source: ABhQp+TjtWZe8eEX7qUjC3i3uxthRsVO6622MnIFWHwTD09ry2igd4+WTYvBWKdPGp/N8P/4kUsvzw== X-Received: by 10.80.151.186 with SMTP id e55mr23272053edb.91.1508921586458; Wed, 25 Oct 2017 01:53:06 -0700 (PDT) Received: from [172.31.0.41] (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id 41sm1474167edz.66.2017.10.25.01.53.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Oct 2017 01:53:05 -0700 (PDT) From: =?utf-8?Q?Javier_Gonz=C3=A1lez?= Message-Id: <05041A94-19A4-42DC-9DA7-5CB0730F4B01@lightnvm.io> Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH] lightnvm: Convert timers to use timer_setup() Date: Wed, 25 Oct 2017 10:53:04 +0200 In-Reply-To: <20171024153004.GA112705@beast> Cc: Jens Axboe , =?utf-8?Q?Matias_Bj=C3=B8rling?= , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org To: Kees Cook References: <20171024153004.GA112705@beast> X-Mailer: Apple Mail (2.3273) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > On 24 Oct 2017, at 17.30, Kees Cook wrote: > > In preparation for unconditionally passing the struct timer_list pointer to > all timer callbacks, switch to using the new timer_setup() and from_timer() > to pass the timer pointer explicitly. > > Cc: Matias Bjorling > Cc: linux-block@vger.kernel.org > Signed-off-by: Kees Cook > --- > drivers/lightnvm/pblk-core.c | 4 ++-- > drivers/lightnvm/pblk-gc.c | 6 +++--- > drivers/lightnvm/pblk-init.c | 2 +- > drivers/lightnvm/pblk-rl.c | 6 +++--- > drivers/lightnvm/pblk.h | 2 +- > drivers/lightnvm/rrpc.c | 6 +++--- > 6 files changed, 13 insertions(+), 13 deletions(-) > > diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c > index 81501644fb15..8841eb66c902 100644 > --- a/drivers/lightnvm/pblk-core.c > +++ b/drivers/lightnvm/pblk-core.c > @@ -229,9 +229,9 @@ static void pblk_write_kick(struct pblk *pblk) > mod_timer(&pblk->wtimer, jiffies + msecs_to_jiffies(1000)); > } > > -void pblk_write_timer_fn(unsigned long data) > +void pblk_write_timer_fn(struct timer_list *t) > { > - struct pblk *pblk = (struct pblk *)data; > + struct pblk *pblk = from_timer(pblk, t, wtimer); > > /* kick the write thread every tick to flush outstanding data */ > pblk_write_kick(pblk); > diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c > index 6090d28f7995..85ff64fe5ba2 100644 > --- a/drivers/lightnvm/pblk-gc.c > +++ b/drivers/lightnvm/pblk-gc.c > @@ -428,9 +428,9 @@ void pblk_gc_kick(struct pblk *pblk) > mod_timer(&gc->gc_timer, jiffies + msecs_to_jiffies(GC_TIME_MSECS)); > } > > -static void pblk_gc_timer(unsigned long data) > +static void pblk_gc_timer(struct timer_list *t) > { > - struct pblk *pblk = (struct pblk *)data; > + struct pblk *pblk = from_timer(pblk, t, gc.gc_timer); > > pblk_gc_kick(pblk); > } > @@ -569,7 +569,7 @@ int pblk_gc_init(struct pblk *pblk) > goto fail_free_writer_kthread; > } > > - setup_timer(&gc->gc_timer, pblk_gc_timer, (unsigned long)pblk); > + timer_setup(&gc->gc_timer, pblk_gc_timer, 0); > mod_timer(&gc->gc_timer, jiffies + msecs_to_jiffies(GC_TIME_MSECS)); > > gc->gc_active = 0; > diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c > index 1b0f61233c21..c0ae85b514f5 100644 > --- a/drivers/lightnvm/pblk-init.c > +++ b/drivers/lightnvm/pblk-init.c > @@ -833,7 +833,7 @@ static int pblk_lines_init(struct pblk *pblk) > > static int pblk_writer_init(struct pblk *pblk) > { > - setup_timer(&pblk->wtimer, pblk_write_timer_fn, (unsigned long)pblk); > + timer_setup(&pblk->wtimer, pblk_write_timer_fn, 0); > mod_timer(&pblk->wtimer, jiffies + msecs_to_jiffies(100)); > > pblk->writer_ts = kthread_create(pblk_write_ts, pblk, "pblk-writer-t"); > diff --git a/drivers/lightnvm/pblk-rl.c b/drivers/lightnvm/pblk-rl.c > index 2e6a5361baf0..1210deeb6f43 100644 > --- a/drivers/lightnvm/pblk-rl.c > +++ b/drivers/lightnvm/pblk-rl.c > @@ -178,9 +178,9 @@ int pblk_rl_sysfs_rate_show(struct pblk_rl *rl) > return rl->rb_user_max; > } > > -static void pblk_rl_u_timer(unsigned long data) > +static void pblk_rl_u_timer(struct timer_list *t) > { > - struct pblk_rl *rl = (struct pblk_rl *)data; > + struct pblk_rl *rl = from_timer(rl, t, u_timer); > > /* Release user I/O state. Protect from GC */ > smp_store_release(&rl->rb_user_active, 0); > @@ -221,7 +221,7 @@ void pblk_rl_init(struct pblk_rl *rl, int budget) > atomic_set(&rl->rb_gc_cnt, 0); > atomic_set(&rl->rb_space, -1); > > - setup_timer(&rl->u_timer, pblk_rl_u_timer, (unsigned long)rl); > + timer_setup(&rl->u_timer, pblk_rl_u_timer, 0); > > rl->rb_user_active = 0; > rl->rb_gc_active = 0; > diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h > index 67e623bd5c2d..e097dea4a1ea 100644 > --- a/drivers/lightnvm/pblk.h > +++ b/drivers/lightnvm/pblk.h > @@ -789,7 +789,7 @@ void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry, > * pblk write thread > */ > int pblk_write_ts(void *data); > -void pblk_write_timer_fn(unsigned long data); > +void pblk_write_timer_fn(struct timer_list *t); > void pblk_write_should_kick(struct pblk *pblk); > > /* > diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c > index 267f01ae87e4..0993c14be860 100644 > --- a/drivers/lightnvm/rrpc.c > +++ b/drivers/lightnvm/rrpc.c > @@ -267,9 +267,9 @@ static void rrpc_gc_kick(struct rrpc *rrpc) > /* > * timed GC every interval. > */ > -static void rrpc_gc_timer(unsigned long data) > +static void rrpc_gc_timer(struct timer_list *t) > { > - struct rrpc *rrpc = (struct rrpc *)data; > + struct rrpc *rrpc = from_timer(rrpc, t, gc_timer); > > rrpc_gc_kick(rrpc); > mod_timer(&rrpc->gc_timer, jiffies + msecs_to_jiffies(10)); > @@ -1063,7 +1063,7 @@ static int rrpc_gc_init(struct rrpc *rrpc) > if (!rrpc->kgc_wq) > return -ENOMEM; > > - setup_timer(&rrpc->gc_timer, rrpc_gc_timer, (unsigned long)rrpc); > + timer_setup(&rrpc->gc_timer, rrpc_gc_timer, 0); > > return 0; > } > -- > 2.7.4 > Looks good. I put it through our daily internal testing (on topof Linus' v4.14-rc6) and it does not seem to introduce any regressions. Reviewed-by: Javier González Tested-by: Javier González One thing though: The patch does not apply on top of Jen's for-15/block. It is trivial, but here you have a version that applies. --- drivers/lightnvm/pblk-core.c | 4 ++-- drivers/lightnvm/pblk-gc.c | 6 +++--- drivers/lightnvm/pblk-init.c | 2 +- drivers/lightnvm/pblk-rl.c | 6 +++--- drivers/lightnvm/pblk.h | 2 +- drivers/lightnvm/rrpc.c | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index ce90213a42fa..76516ee84e9a 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -270,9 +270,9 @@ static void pblk_write_kick(struct pblk *pblk) mod_timer(&pblk->wtimer, jiffies + msecs_to_jiffies(1000)); } -void pblk_write_timer_fn(unsigned long data) +void pblk_write_timer_fn(struct timer_list *t) { - struct pblk *pblk = (struct pblk *)data; + struct pblk *pblk = from_timer(pblk, t, wtimer); /* kick the write thread every tick to flush outstanding data */ pblk_write_kick(pblk); diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c index 00d5698d64a9..9c8e114c8a54 100644 --- a/drivers/lightnvm/pblk-gc.c +++ b/drivers/lightnvm/pblk-gc.c @@ -442,9 +442,9 @@ static void pblk_gc_run(struct pblk *pblk) goto next_gc_group; } -static void pblk_gc_timer(unsigned long data) +static void pblk_gc_timer(struct timer_list *t) { - struct pblk *pblk = (struct pblk *)data; + struct pblk *pblk = from_timer(pblk, t, gc.gc_timer); pblk_gc_kick(pblk); } @@ -601,7 +601,7 @@ int pblk_gc_init(struct pblk *pblk) goto fail_free_writer_kthread; } - setup_timer(&gc->gc_timer, pblk_gc_timer, (unsigned long)pblk); + timer_setup(&gc->gc_timer, pblk_gc_timer, 0); mod_timer(&gc->gc_timer, jiffies + msecs_to_jiffies(GC_TIME_MSECS)); gc->gc_active = 0; diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index f62112ba5482..695826a06b5d 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -866,7 +866,7 @@ static int pblk_lines_init(struct pblk *pblk) static int pblk_writer_init(struct pblk *pblk) { - setup_timer(&pblk->wtimer, pblk_write_timer_fn, (unsigned long)pblk); + timer_setup(&pblk->wtimer, pblk_write_timer_fn, 0); mod_timer(&pblk->wtimer, jiffies + msecs_to_jiffies(100)); pblk->writer_ts = kthread_create(pblk_write_ts, pblk, "pblk-writer-t"); diff --git a/drivers/lightnvm/pblk-rl.c b/drivers/lightnvm/pblk-rl.c index abae31fd434e..dacc71922260 100644 --- a/drivers/lightnvm/pblk-rl.c +++ b/drivers/lightnvm/pblk-rl.c @@ -158,9 +158,9 @@ int pblk_rl_max_io(struct pblk_rl *rl) return rl->rb_max_io; } -static void pblk_rl_u_timer(unsigned long data) +static void pblk_rl_u_timer(struct timer_list *t) { - struct pblk_rl *rl = (struct pblk_rl *)data; + struct pblk_rl *rl = from_timer(rl, t, u_timer); /* Release user I/O state. Protect from GC */ smp_store_release(&rl->rb_user_active, 0); @@ -202,7 +202,7 @@ void pblk_rl_init(struct pblk_rl *rl, int budget) atomic_set(&rl->rb_gc_cnt, 0); atomic_set(&rl->rb_space, -1); - setup_timer(&rl->u_timer, pblk_rl_u_timer, (unsigned long)rl); + timer_setup(&rl->u_timer, pblk_rl_u_timer, 0); rl->rb_user_active = 0; rl->rb_gc_active = 0; diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index 90961033a79f..59a64d461a5d 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -797,7 +797,7 @@ void pblk_map_rq(struct pblk *pblk, struct nvm_rq *rqd, unsigned int sentry, * pblk write thread */ int pblk_write_ts(void *data); -void pblk_write_timer_fn(unsigned long data); +void pblk_write_timer_fn(struct timer_list *t); void pblk_write_should_kick(struct pblk *pblk); /* diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index 267f01ae87e4..0993c14be860 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -267,9 +267,9 @@ static void rrpc_gc_kick(struct rrpc *rrpc) /* * timed GC every interval. */ -static void rrpc_gc_timer(unsigned long data) +static void rrpc_gc_timer(struct timer_list *t) { - struct rrpc *rrpc = (struct rrpc *)data; + struct rrpc *rrpc = from_timer(rrpc, t, gc_timer); rrpc_gc_kick(rrpc); mod_timer(&rrpc->gc_timer, jiffies + msecs_to_jiffies(10)); @@ -1063,7 +1063,7 @@ static int rrpc_gc_init(struct rrpc *rrpc) if (!rrpc->kgc_wq) return -ENOMEM; - setup_timer(&rrpc->gc_timer, rrpc_gc_timer, (unsigned long)rrpc); + timer_setup(&rrpc->gc_timer, rrpc_gc_timer, 0); return 0; }