1. 12 11月, 2017 2 次提交
    • D
      timers: Add a function to start/reduce a timer · b24591e2
      David Howells 提交于
      Add a function, similar to mod_timer(), that will start a timer if it isn't
      running and will modify it if it is running and has an expiry time longer
      than the new time.  If the timer is running with an expiry time that's the
      same or sooner, no change is made.
      
      The function looks like:
      
      	int timer_reduce(struct timer_list *timer, unsigned long expires);
      
      This can be used by code such as networking code to make it easier to share
      a timer for multiple timeouts.  For instance, in upcoming AF_RXRPC code,
      the rxrpc_call struct will maintain a number of timeouts:
      
      	unsigned long	ack_at;
      	unsigned long	resend_at;
      	unsigned long	ping_at;
      	unsigned long	expect_rx_by;
      	unsigned long	expect_req_by;
      	unsigned long	expect_term_by;
      
      each of which is set independently of the others.  With timer reduction
      available, when the code needs to set one of the timeouts, it only needs to
      look at that timeout and then call timer_reduce() to modify the timer,
      starting it or bringing it forward if necessary.  There is no need to refer
      to the other timeouts to see which is earliest and no need to take any lock
      other than, potentially, the timer lock inside timer_reduce().
      
      Note, that this does not protect against concurrent invocations of any of
      the timer functions.
      
      As an example, the expect_rx_by timeout above, which terminates a call if
      we don't get a packet from the server within a certain time window, would
      be set something like this:
      
      	unsigned long now = jiffies;
      	unsigned long expect_rx_by = now + packet_receive_timeout;
      	WRITE_ONCE(call->expect_rx_by, expect_rx_by);
      	timer_reduce(&call->timer, expect_rx_by);
      
      The timer service code (which might, say, be in a work function) would then
      check all the timeouts to see which, if any, had triggered, deal with
      those:
      
      	t = READ_ONCE(call->ack_at);
      	if (time_after_eq(now, t)) {
      		cmpxchg(&call->ack_at, t, now + MAX_JIFFY_OFFSET);
      		set_bit(RXRPC_CALL_EV_ACK, &call->events);
      	}
      
      and then restart the timer if necessary by finding the soonest timeout that
      hasn't yet passed and then calling timer_reduce().
      
      The disadvantage of doing things this way rather than comparing the timers
      each time and calling mod_timer() is that you *will* take timer events
      unless you can finish what you're doing and delete the timer in time.
      
      The advantage of doing things this way is that you don't need to use a lock
      to work out when the next timer should be set, other than the timer's own
      lock - which you might not have to take.
      
      [ tglx: Fixed weird formatting and adopted it to pending changes ]
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: keyrings@vger.kernel.org
      Cc: linux-afs@lists.infradead.org
      Link: https://lkml.kernel.org/r/151023090769.23050.1801643667223880753.stgit@warthog.procyon.org.uk
      b24591e2
    • A
      pstore: Use ktime_get_real_fast_ns() instead of __getnstimeofday() · df27067e
      Arnd Bergmann 提交于
      __getnstimeofday() is a rather odd interface, with a number of quirks:
      
      - The caller may come from NMI context, but the implementation is not NMI safe,
        one way to get there from NMI is
      
            NMI handler:
              something bad
                panic()
                  kmsg_dump()
                    pstore_dump()
                       pstore_record_init()
                         __getnstimeofday()
      
      - The calling conventions are different from any other timekeeping functions,
        to deal with returning an error code during suspended timekeeping.
      
      Address the above issues by using a completely different method to get the
      time: ktime_get_real_fast_ns() is NMI safe and has a reasonable behavior
      when timekeeping is suspended: it returns the time at which it got
      suspended. As Thomas Gleixner explained, this is safe, as
      ktime_get_real_fast_ns() does not call into the clocksource driver that
      might be suspended.
      
      The result can easily be transformed into a timespec structure. Since
      ktime_get_real_fast_ns() was not exported to modules, add the export.
      
      The pstore behavior for the suspended case changes slightly, as it now
      stores the timestamp at which timekeeping was suspended instead of storing
      a zero timestamp.
      
      This change is not addressing y2038-safety, that's subject to a more
      complex follow up patch.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NKees Cook <keescook@chromium.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Anton Vorontsov <anton@enomsg.org>
      Cc: Stephen Boyd <sboyd@codeaurora.org>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Colin Cross <ccross@android.com>
      Link: https://lkml.kernel.org/r/20171110152530.1926955-1-arnd@arndb.de
      df27067e
  2. 09 11月, 2017 4 次提交
  3. 07 11月, 2017 8 次提交
    • T
      Merge tag 'timers-conversion-next4' of... · 1c10bbee
      Thomas Gleixner 提交于
      Merge tag 'timers-conversion-next4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux into timers/core
      
      Pull the 4th timer conversion batch from Kees Cook
      
       - A couple fixes for less common build configurations
      
       - More stragglers that have either been reviewed or gone
         long enough on list
      1c10bbee
    • K
      block/aoe: discover_timer: Convert timers to use timer_setup() · 5ea22086
      Kees Cook 提交于
      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.
      
      This refactors the discover_timer to remove the needless locking and
      state machine used for synchronizing timer death. Using del_timer_sync()
      will already do the right thing.
      
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: "Ed L. Cashin" <ed.cashin@acm.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      5ea22086
    • K
      ide: Convert timers to use timer_setup() · 10738ba8
      Kees Cook 提交于
      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: "David S. Miller" <davem@davemloft.net>
      Cc: linux-ide@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      10738ba8
    • K
      drbd: Convert timers to use timer_setup() · 2bccef39
      Kees Cook 提交于
      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: Philipp Reisner <philipp.reisner@linbit.com>
      Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
      Cc: drbd-dev@lists.linbit.com
      Signed-off-by: NKees Cook <keescook@chromium.org>
      2bccef39
    • K
      mailbox: Convert timers to use timer_setup() · c6f15047
      Kees Cook 提交于
      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: Ley Foon Tan <lftan@altera.com>
      Cc: Jassi Brar <jassisinghbrar@gmail.com>
      Cc: nios2-dev@lists.rocketboards.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      c6f15047
    • K
      crypto: Convert timers to use timer_setup() · f34d8d50
      Kees Cook 提交于
      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: Jesper Nilsson <jesper.nilsson@axis.com>
      Cc: Lars Persson <lars.persson@axis.com>
      Cc: Niklas Cassel <niklas.cassel@axis.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jamie Iles <jamie@jamieiles.com>
      Cc: linux-arm-kernel@axis.com
      Cc: linux-crypto@vger.kernel.org
      Cc: linux-arm-kernel@lists.infradead.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: NJamie Iles <jamie@jamieiles.com>
      Acked-by: Lars Persson <lars.persson@axis.com> # for axis
      f34d8d50
    • K
      drivers/pcmcia: omap1: Fix error in automated timer conversion · 439dc05f
      Kees Cook 提交于
      One part of automated timer conversion tools did not take into account
      void * variables when searching out prior direct timer callback usage,
      which resulted in an attempt to dereference the timer field without a
      proper type.
      
      Reported-by: kbuild test robot
      Signed-off-by: NKees Cook <keescook@chromium.org>
      439dc05f
    • K
      ARM: footbridge: Fix typo in timer conversion · 14c8276d
      Kees Cook 提交于
      This fixes a missing semi-colon. It went unnoticed initially since it is
      only built under certain defconfigs.
      
      Reported-by: kbuild test robot
      Signed-off-by: NKees Cook <keescook@chromium.org>
      14c8276d
  4. 03 11月, 2017 22 次提交
    • T
      Merge tag 'timers-conversion-next3' of... · c7c2f3d9
      Thomas Gleixner 提交于
      Merge tag 'timers-conversion-next3' of https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux into timers/core
      
      Pull the 3rd batch of timer conversions from Kees Cook:
      
       - various per-architecture conversions
       - several driver conversions not picked up by a specific maintainer
       - other Acked/Reviewed conversions to go through tip
      c7c2f3d9
    • K
      drivers/sgi-xp: Convert timers to use timer_setup() · 25b42fa8
      Kees Cook 提交于
      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: Cliff Whickman <cpw@sgi.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: NRobin Holt <robinmholt@gmail.com>
      25b42fa8
    • K
      drivers/pcmcia: Convert timers to use timer_setup() · 41760d0e
      Kees Cook 提交于
      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: Florian Fainelli <f.fainelli@gmail.com>
      Cc: bcm-kernel-feedback-list@broadcom.com
      Cc: David Howells <dhowells@redhat.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: linux-pcmcia@lists.infradead.org
      Cc: linux-arm-kernel@lists.infradead.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: Russell King <rmk+kernel@armlinux.org.uk> # for soc_common.c
      41760d0e
    • K
      drivers/memstick: Convert timers to use timer_setup() · 6243d38f
      Kees Cook 提交于
      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: Maxim Levitsky <maximlevitsky@gmail.com>
      Cc: Alex Dubov <oakad@yahoo.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      6243d38f
    • K
      drivers/macintosh: Convert timers to use timer_setup() · 0788f285
      Kees Cook 提交于
      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: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      0788f285
    • K
      hwrng/xgene-rng: Convert timers to use timer_setup() · 200d24d6
      Kees Cook 提交于
      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: Matt Mackall <mpm@selenic.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: linux-crypto@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      200d24d6
    • K
      auxdisplay: Convert timers to use timer_setup() · 607a6301
      Kees Cook 提交于
      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: Paul Burton <paul.burton@imgtec.com>
      Cc: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NPaul Burton <paul.burton@mips.com>
      Tested-by: Paul Burton <paul.burton@mips.com> # for img-ascii-lcd
      607a6301
    • K
      sparc/led: Convert timers to use timer_setup() · db275f2a
      Kees Cook 提交于
      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. Adds a static variable to hold timeout
      value.
      
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Geliang Tang <geliangtang@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: sparclinux@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      db275f2a
    • K
      mips: ip22/32: Convert timers to use timer_setup() · a66b899d
      Kees Cook 提交于
      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. Adds a static variable to hold timeout
      value.
      
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: linux-mips@linux-mips.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      a66b899d
    • K
      arm: pxa: Convert timers to use timer_setup() · 96d13082
      Kees Cook 提交于
      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. Adds a static variable to hold the
      interrupt private data pointer.
      
      Cc: Daniel Mack <daniel@zonque.org>
      Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
      Cc: Robert Jarzmik <robert.jarzmik@free.fr>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: linux-arm-kernel@lists.infradead.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      96d13082
    • K
      ARM: footbridge: Convert timers to use timer_setup() · b7bea32f
      Kees Cook 提交于
      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: Russell King <linux@armlinux.org.uk>
      Cc: linux-arm-kernel@lists.infradead.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      b7bea32f
    • K
      ia64: Convert timers to use timer_setup() · 2c513d4f
      Kees Cook 提交于
      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.
      
      One less trivial change was removing the repeated casting for callers
      of bte_error_handler() by fixing its function declaration and adding a
      small wrapper for the timer callback instead.
      
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Joe Perches <joe@perches.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: linux-ia64@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      2c513d4f
    • K
      xtensa: Convert timers to use timer_setup() · d8479a21
      Kees Cook 提交于
      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: Chris Zankel <chris@zankel.net>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: linux-xtensa@linux-xtensa.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      d8479a21
    • K
      x86, calgary: Convert timers to use timer_setup() · 3142692a
      Kees Cook 提交于
      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: Muli Ben-Yehuda <mulix@mulix.org>
      Cc: Jon Mason <jdmason@kudzu.us>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: x86@kernel.org
      Cc: iommu@lists.linux-foundation.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      3142692a
    • K
      powerpc/watchdog: Convert timers to use timer_setup() · 5943cf4a
      Kees Cook 提交于
      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: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      5943cf4a
    • K
      watchdog: lpc18xx_wdt: Convert timers to use timer_setup() · d1cadcb7
      Kees Cook 提交于
      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: Wim Van Sebroeck <wim@iguana.be>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Joachim Eastwood <manabian@gmail.com>
      Cc: linux-watchdog@vger.kernel.org
      Cc: linux-arm-kernel@lists.infradead.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: NGuenter Roeck <linux@roeck-us.net>
      d1cadcb7
    • K
      watchdog: cpwd: Convert timers to use timer_setup() · 4fa42b4e
      Kees Cook 提交于
      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. Switches to using the global that is
      used everywhere else.
      
      Cc: Wim Van Sebroeck <wim@iguana.be>
      Cc: linux-watchdog@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      4fa42b4e
    • K
      media: pvrusb2: Convert timers to use timer_setup() · 8da0edf2
      Kees Cook 提交于
      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: Mike Isely <isely@pobox.com>
      Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
      Cc: linux-media@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-By: NMike Isely <isely@pobox.com>
      Acked-by: NHans Verkuil <hans.verkuil@cisco.com>
      8da0edf2
    • K
      drm/etnaviv: Convert timers to use timer_setup() · 43b70524
      Kees Cook 提交于
      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: Lucas Stach <l.stach@pengutronix.de>
      Cc: Russell King <linux+etnaviv@armlinux.org.uk>
      Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
      Cc: David Airlie <airlied@linux.ie>
      Cc: etnaviv@lists.freedesktop.org
      Cc: dri-devel@lists.freedesktop.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      43b70524
    • K
      ACPI / APEI: Convert timers to use timer_setup() · d5272003
      Kees Cook 提交于
      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: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Tyler Baicar <tbaicar@codeaurora.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: James Morse <james.morse@arm.com>
      Cc: "Jonathan (Zhixiong) Zhang" <zjzhang@codeaurora.org>
      Cc: Shiju Jose <shiju.jose@huawei.com>
      Cc: linux-acpi@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Tested-by: NTyler Baicar <tbaicar@codeaurora.org>
      d5272003
    • K
      fs/ncpfs: Convert timers to use timer_setup() · 9b5dfbdd
      Kees Cook 提交于
      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: Petr Vandrovec <petr@vandrovec.name>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Jens Axboe <axboe@fb.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NJan Kara <jack@suse.cz>
      9b5dfbdd
    • K
      rcu: Convert timers to use timer_setup() · fd30b717
      Kees Cook 提交于
      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: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Lai Jiangshan <jiangshanlai@gmail.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      fd30b717
  5. 02 11月, 2017 4 次提交