Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 98027
b: refs/heads/master
c: 95dcf83
h: refs/heads/master
i:
  98025: 7cd20e1
  98023: f42e7e5
v: v3
  • Loading branch information
Linus Torvalds committed Jun 12, 2008
1 parent 0349c38 commit e7755f6
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4d7365d664e79710ac0e782a23443471ddf05bdd
refs/heads/master: 95dcf8350dc889e735d03c0debe2f7b26d243185
13 changes: 3 additions & 10 deletions trunk/arch/x86/xen/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/clocksource.h>
#include <linux/clockchips.h>
#include <linux/kernel_stat.h>
#include <linux/math64.h>

#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
Expand Down Expand Up @@ -150,11 +151,7 @@ static void do_stolen_accounting(void)
if (stolen < 0)
stolen = 0;

ticks = 0;
while (stolen >= NS_PER_TICK) {
ticks++;
stolen -= NS_PER_TICK;
}
ticks = iter_div_u64_rem(stolen, NS_PER_TICK, &stolen);
__get_cpu_var(residual_stolen) = stolen;
account_steal_time(NULL, ticks);

Expand All @@ -166,11 +163,7 @@ static void do_stolen_accounting(void)
if (blocked < 0)
blocked = 0;

ticks = 0;
while (blocked >= NS_PER_TICK) {
ticks++;
blocked -= NS_PER_TICK;
}
ticks = iter_div_u64_rem(blocked, NS_PER_TICK, &blocked);
__get_cpu_var(residual_blocked) = blocked;
account_steal_time(idle_task(smp_processor_id()), ticks);
}
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/video/fsl-diu-fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ static void free_irq_local(int irq)
* Power management hooks. Note that we won't be called from IRQ context,
* unlike the blank functions above, so we may sleep.
*/
static int fsl_diu_suspend(struct of_device *dev, pm_message_t state)
static int fsl_diu_suspend(struct of_device *ofdev, pm_message_t state)
{
struct fsl_diu_data *machine_data;

Expand All @@ -1330,7 +1330,7 @@ static int fsl_diu_suspend(struct of_device *dev, pm_message_t state)
return 0;
}

static int fsl_diu_resume(struct of_device *dev)
static int fsl_diu_resume(struct of_device *ofdev)
{
struct fsl_diu_data *machine_data;

Expand Down
21 changes: 21 additions & 0 deletions trunk/include/linux/math64.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,25 @@ static inline s64 div_s64(s64 dividend, s32 divisor)
}
#endif

u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder);

static __always_inline u32
__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
{
u32 ret = 0;

while (dividend >= divisor) {
/* The following asm() prevents the compiler from
optimising this loop into a modulo operation. */
asm("" : "+rm"(dividend));

dividend -= divisor;
ret++;
}

*remainder = dividend;

return ret;
}

#endif /* _LINUX_MATH64_H */
16 changes: 6 additions & 10 deletions trunk/include/linux/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifdef __KERNEL__
# include <linux/cache.h>
# include <linux/seqlock.h>
# include <linux/math64.h>
#endif

#ifndef _STRUCT_TIMESPEC
Expand Down Expand Up @@ -169,18 +170,13 @@ extern struct timeval ns_to_timeval(const s64 nsec);
* timespec_add_ns - Adds nanoseconds to a timespec
* @a: pointer to timespec to be incremented
* @ns: unsigned nanoseconds value to be added
*
* This must always be inlined because its used from the x86-64 vdso,
* which cannot call other kernel functions.
*/
static inline void timespec_add_ns(struct timespec *a, u64 ns)
static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
{
ns += a->tv_nsec;
while(unlikely(ns >= NSEC_PER_SEC)) {
/* The following asm() prevents the compiler from
* optimising this loop into a modulo operation. */
asm("" : "+r"(ns));

ns -= NSEC_PER_SEC;
a->tv_sec++;
}
a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
a->tv_nsec = ns;
}
#endif /* __KERNEL__ */
Expand Down
10 changes: 10 additions & 0 deletions trunk/lib/div64.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,13 @@ EXPORT_SYMBOL(div64_u64);
#endif

#endif /* BITS_PER_LONG == 32 */

/*
* Iterative div/mod for use when dividend is not expected to be much
* bigger than divisor.
*/
u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
{
return __iter_div_u64_rem(dividend, divisor, remainder);
}
EXPORT_SYMBOL(iter_div_u64_rem);
21 changes: 3 additions & 18 deletions trunk/mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,15 @@ EXPORT_SYMBOL(vmtruncate);
unsigned int kobjsize(const void *objp)
{
struct page *page;
int order = 0;

/*
* If the object we have should not have ksize performed on it,
* return size of 0
*/
if (!objp)
return 0;

if ((unsigned long)objp >= memory_end)
if (!objp || !virt_addr_valid(objp))
return 0;

page = virt_to_head_page(objp);
if (!page)
return 0;

/*
* If the allocator sets PageSlab, we know the pointer came from
Expand All @@ -129,18 +123,9 @@ unsigned int kobjsize(const void *objp)

/*
* The ksize() function is only guaranteed to work for pointers
* returned by kmalloc(). So handle arbitrary pointers, that we expect
* always to be compound pages, here.
*/
if (PageCompound(page))
order = compound_order(page);

/*
* Finally, handle arbitrary pointers that don't set PageSlab.
* Default to 0-order in the case when we're unable to ksize()
* the object.
* returned by kmalloc(). So handle arbitrary pointers here.
*/
return PAGE_SIZE << order;
return PAGE_SIZE << compound_order(page);
}

/*
Expand Down

0 comments on commit e7755f6

Please sign in to comment.