counter.h (4e76af6a41e490a83f615cd9104bc7107ad3eef5) counter.h (706c56e4a9c40faaac5ad4fb91e9128eafe186ce)
1/*-
2 * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 32 unchanged lines hidden (view full) ---

41 critical_enter(); \
42} while (0)
43
44#define counter_exit() do { \
45 if ((cpu_feature & CPUID_CX8) == 0) \
46 critical_exit(); \
47} while (0)
48
1/*-
2 * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 32 unchanged lines hidden (view full) ---

41 critical_enter(); \
42} while (0)
43
44#define counter_exit() do { \
45 if ((cpu_feature & CPUID_CX8) == 0) \
46 critical_exit(); \
47} while (0)
48
49extern struct pcpu __pcpu[MAXCPU];
50
49static inline void
50counter_64_inc_8b(uint64_t *p, int64_t inc)
51{
52
53 __asm __volatile(
54 "movl %%fs:(%%esi),%%eax\n\t"
55 "movl %%fs:4(%%esi),%%edx\n"
56"1:\n\t"
57 "movl %%eax,%%ebx\n\t"
58 "movl %%edx,%%ecx\n\t"
59 "addl (%%edi),%%ebx\n\t"
60 "adcl 4(%%edi),%%ecx\n\t"
61 "cmpxchg8b %%fs:(%%esi)\n\t"
62 "jnz 1b"
63 :
51static inline void
52counter_64_inc_8b(uint64_t *p, int64_t inc)
53{
54
55 __asm __volatile(
56 "movl %%fs:(%%esi),%%eax\n\t"
57 "movl %%fs:4(%%esi),%%edx\n"
58"1:\n\t"
59 "movl %%eax,%%ebx\n\t"
60 "movl %%edx,%%ecx\n\t"
61 "addl (%%edi),%%ebx\n\t"
62 "adcl 4(%%edi),%%ecx\n\t"
63 "cmpxchg8b %%fs:(%%esi)\n\t"
64 "jnz 1b"
65 :
64 : "S" (p), "D" (&inc)
66 : "S" ((char *)p - (char *)&__pcpu[0]), "D" (&inc)
65 : "memory", "cc", "eax", "edx", "ebx", "ecx");
66}
67
68#define counter_u64_add_protected(c, inc) do { \
69 if ((cpu_feature & CPUID_CX8) == 0) { \
70 CRITICAL_ASSERT(curthread); \
71 *(uint64_t *)zpcpu_get(c) += (inc); \
72 } else \

--- 17 unchanged lines hidden ---
67 : "memory", "cc", "eax", "edx", "ebx", "ecx");
68}
69
70#define counter_u64_add_protected(c, inc) do { \
71 if ((cpu_feature & CPUID_CX8) == 0) { \
72 CRITICAL_ASSERT(curthread); \
73 *(uint64_t *)zpcpu_get(c) += (inc); \
74 } else \

--- 17 unchanged lines hidden ---