Being of type unsigned long, the struct clock_event_device's ->retries
member is incremented in clockevents_program_min_delta() and used for
diagnostic purposes in /proc/timer_list only.

Turning ->retries' type into unsigned int avoids the introduction of
some padding with future reorderings of struct clock_event_device for the
case of sizeof(unsigned long) == sizeof(void*) == 8. This is turn prevents
these reorganizations from making sizeof(struct clock_event_device) cross
a multiple of the cacheline size, assumed to be equal to 64 bytes.

For the case of HZ=1000, this change still allows for
2^32 / HZ / (3600*24) = 49 days without overwrap, even in the highly
unrealistic case of one clockevents_program_min_delta() invocation per
tick.

Thus, change ->retries' type from unsigned long to unsigned int. Adapt
the format specifier or /proc/timer_list accordingly.

Signed-off-by: Nicolai Stange <nicsta...@gmail.com>
---
 include/linux/clockchips.h | 2 +-
 kernel/time/timer_list.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index e07f421..878a802 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -115,7 +115,7 @@ struct clock_event_device {
        u32                     shift;
        enum clock_event_state  state_use_accessors:8;
        unsigned int            features:24;
-       unsigned long           retries;
+       unsigned int            retries;
 
        int                     (*set_state_periodic)(struct clock_event_device 
*);
        int                     (*set_state_oneshot)(struct clock_event_device 
*);
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 9067760..6a8d54f 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -271,7 +271,7 @@ print_tickdevice(struct seq_file *m, struct tick_device 
*td, int cpu)
        SEQ_printf(m, " event_handler:  ");
        print_name_offset(m, dev->event_handler);
        SEQ_printf(m, "\n");
-       SEQ_printf(m, " retries:        %lu\n", dev->retries);
+       SEQ_printf(m, " retries:        %u\n", dev->retries);
        SEQ_printf(m, "\n");
 }
 
-- 
2.10.2

Reply via email to