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: 9985889 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 75B7D602B8 for ; Wed, 4 Oct 2017 23:29:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66A1526E96 for ; Wed, 4 Oct 2017 23:29:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5969F27F82; Wed, 4 Oct 2017 23:29:11 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham 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 B06A026E96 for ; Wed, 4 Oct 2017 23:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751910AbdJDX3G (ORCPT ); Wed, 4 Oct 2017 19:29:06 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:45035 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751639AbdJDX2I (ORCPT ); Wed, 4 Oct 2017 19:28:08 -0400 Received: by mail-pf0-f179.google.com with SMTP id t62so5849982pfd.1 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=W41WHvkS9kAtPoum1XZAA+l7kcjV0KOkFWTi6aM96n3fBih77sQgxvindOHyn6zNHq o+LILt1YGcn2YZHmXoH8o6Oh7gbjCvsnt7tDL2NWGJa7F3mHODULoTH7Qz7LlpyYu3rH NSX6JBid2jX4Lo8daVDfnY1aWSmQYmkTffkNMRhY6JZS4NNtiie6+LMY6OY0ImKc1QS8 qjEK7ahrMTJW5IMvVI2hpoXknis5nahTWQIFYkFTTAe3eWvoWzaul9QcytzwdRehcJZS i+CGhYnAF1bvexR28e+v3LaX/76U0c/K4QcHVnfBExyZUCXAZjx493/0mgk7Kvau4cTA nN4g== X-Gm-Message-State: AMCzsaXpVcqcle7ksw8yKSlVm6nmEGxqZei4s0xU6BewBV9pUDqbsUAg Dd0OJ/DvXA5Glog5UQDKjYE8Kg== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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