From patchwork Wed Oct 4 23:27:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9985917 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 9617D602B8 for ; Wed, 4 Oct 2017 23:31:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8809F28C1A for ; Wed, 4 Oct 2017 23:31:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C5FD28C24; Wed, 4 Oct 2017 23:31:21 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 E836728C1A for ; Wed, 4 Oct 2017 23:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751926AbdJDX3H (ORCPT ); Wed, 4 Oct 2017 19:29:07 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:48908 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751642AbdJDX2I (ORCPT ); Wed, 4 Oct 2017 19:28:08 -0400 Received: by mail-pf0-f169.google.com with SMTP id n24so7034905pfk.5 for ; Wed, 04 Oct 2017 16:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qWhl+ozP//rPItOLapomnr7Om6Pai3qir5alpg2/EHM=; b=QUMbvx1hGUXobjOS1WgmwIapI6wOIaJpxEQaHKIQobF1/QoZmlCsOVLZv2n2CdmbI2 pARZtZkCh7FN2/EpyuyoeLUzWKxRmTvlqIJO4wTY5dol2KemT0XoPvMjW12E22uvsqu/ 5WyEBGqbEfo5v5Q5qk1U52atawqW3zisFGJ8Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qWhl+ozP//rPItOLapomnr7Om6Pai3qir5alpg2/EHM=; b=WSqrW3Dp8FFhIH/sdb8x3EaHDaj2ENixqt3KQaQClMBbfzB0l6x6KF9t6ZT+M/wtww o1HtNPcMetMGmEb+w30tcRC2KKBpGtES1BNN7w8GQ6vToY4Ft5JYFmpLOrwlx+mJHScd x9bKqzJkAa8dri4+5KV4+rZ9pL8fGYgLyQJ0NHF+i2no2JcfZYRIPzB7yfGOchlljDJE 7Sx4hCAqw1w1a9FSWg+5zH7FOR3oxSfZTa3HE8Cgz38zCVe+tdtPqmbhGa0BqkQ6d5/4 bdFm0Rf0QSKsSStJ65Qq09TY/V37HBAIwT1b6HBKyqJhcQeY+E5D857YQQI3uihkaNlE /brA== X-Gm-Message-State: AMCzsaXlKe+ZvkhuwGN4vzYajH3hLbd+RnVhuXByoHHA82ybQvGgiSPy 4a9lLM8TO0k+XiVANSTEA3M7MA== X-Google-Smtp-Source: AOwi7QC6op5nWi557zfz9/okY8sC6FtmjMT+EmeAkiPxndf7CtwOa+OXXa6ALCSMhnAvo87ZleV+kQ== X-Received: by 10.98.60.14 with SMTP id j14mr4223879pfa.234.1507159688265; Wed, 04 Oct 2017 16:28:08 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id d12sm14438153pfl.140.2017.10.04.16.27.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 16:28:04 -0700 (PDT) From: Kees Cook To: Thomas Gleixner Cc: Kees Cook , Andrew Morton , Petr Mladek , Tejun Heo , Oleg Nesterov , Arnd Bergmann , Benjamin Herrenschmidt , Chris Metcalf , Geert Uytterhoeven , Greg Kroah-Hartman , Guenter Roeck , Harish Patil , Heiko Carstens , "James E.J. Bottomley" , John Stultz , Julian Wiedmann , Kalle Valo , Lai Jiangshan , Len Brown , Manish Chopra , Mark Gross , "Martin K. Petersen" , Martin Schwidefsky , Michael Ellerman , Michael Reed , netdev@vger.kernel.org, Paul Mackerras , Pavel Machek , "Rafael J. Wysocki" , Ralf Baechle , Sebastian Reichel , Stefan Richter , Stephen Boyd , Sudip Mukherjee , Ursula Braun , Viresh Kumar , Wim Van Sebroeck , linux1394-devel@lists.sourceforge.net, linux-mips@linux-mips.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/13] kthread: Convert callback to use from_timer() Date: Wed, 4 Oct 2017 16:27:06 -0700 Message-Id: <1507159627-127660-13-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507159627-127660-1-git-send-email-keescook@chromium.org> References: <1507159627-127660-1-git-send-email-keescook@chromium.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch kthread to use from_timer() and pass the timer pointer explicitly. Cc: Andrew Morton Cc: Petr Mladek Cc: Tejun Heo Cc: Thomas Gleixner Cc: Oleg Nesterov Signed-off-by: Kees Cook Reviewed-by: Petr Mladek --- include/linux/kthread.h | 10 +++++----- kernel/kthread.c | 10 ++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/linux/kthread.h b/include/linux/kthread.h index 0d622b350d3f..35cbe3b0ce5b 100644 --- a/include/linux/kthread.h +++ b/include/linux/kthread.h @@ -75,7 +75,7 @@ extern int tsk_fork_get_node(struct task_struct *tsk); */ struct kthread_work; typedef void (*kthread_work_func_t)(struct kthread_work *work); -void kthread_delayed_work_timer_fn(unsigned long __data); +void kthread_delayed_work_timer_fn(struct timer_list *t); enum { KTW_FREEZABLE = 1 << 0, /* freeze during suspend */ @@ -116,8 +116,8 @@ struct kthread_delayed_work { #define KTHREAD_DELAYED_WORK_INIT(dwork, fn) { \ .work = KTHREAD_WORK_INIT((dwork).work, (fn)), \ - .timer = __TIMER_INITIALIZER(kthread_delayed_work_timer_fn, \ - (unsigned long)&(dwork), \ + .timer = __TIMER_INITIALIZER((TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn,\ + (TIMER_DATA_TYPE)&(dwork.timer), \ TIMER_IRQSAFE), \ } @@ -164,8 +164,8 @@ extern void __kthread_init_worker(struct kthread_worker *worker, do { \ kthread_init_work(&(dwork)->work, (fn)); \ __setup_timer(&(dwork)->timer, \ - kthread_delayed_work_timer_fn, \ - (unsigned long)(dwork), \ + (TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn,\ + (TIMER_DATA_TYPE)&(dwork)->timer, \ TIMER_IRQSAFE); \ } while (0) diff --git a/kernel/kthread.c b/kernel/kthread.c index 1c19edf82427..ba3992c8c375 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -798,15 +798,14 @@ EXPORT_SYMBOL_GPL(kthread_queue_work); /** * kthread_delayed_work_timer_fn - callback that queues the associated kthread * delayed work when the timer expires. - * @__data: pointer to the data associated with the timer + * @t: pointer to the expired timer * * The format of the function is defined by struct timer_list. * It should have been called from irqsafe timer with irq already off. */ -void kthread_delayed_work_timer_fn(unsigned long __data) +void kthread_delayed_work_timer_fn(struct timer_list *t) { - struct kthread_delayed_work *dwork = - (struct kthread_delayed_work *)__data; + struct kthread_delayed_work *dwork = from_timer(dwork, t, timer); struct kthread_work *work = &dwork->work; struct kthread_worker *worker = work->worker; @@ -837,8 +836,7 @@ void __kthread_queue_delayed_work(struct kthread_worker *worker, struct timer_list *timer = &dwork->timer; struct kthread_work *work = &dwork->work; - WARN_ON_ONCE(timer->function != kthread_delayed_work_timer_fn || - timer->data != (unsigned long)dwork); + WARN_ON_ONCE(timer->function != (TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn); /* * If @delay is 0, queue @dwork->work immediately. This is for