* [ceph-client:tls_logger 6/13] net/ceph/ceph_san.c:17:39: sparse: sparse: incorrect type in initializer (different address spaces)
@ 2025-02-13 16:32 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-02-13 16:32 UTC (permalink / raw)
To: Alex Markuze; +Cc: oe-kbuild-all, ceph-devel
tree: https://github.com/ceph/ceph-client.git tls_logger
head: cd1e899feeb6a7da55cbb74b9245c8bbb77f82ba
commit: 485747e7711ebb9bcda819027564d587d215874a [6/13] ceph_san: moving to per_cpu
config: alpha-randconfig-r133-20250213 (https://download.01.org/0day-ci/archive/20250214/202502140048.RiHSMZiW-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 14.2.0
reproduce: (https://download.01.org/0day-ci/archive/20250214/202502140048.RiHSMZiW-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502140048.RiHSMZiW-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
net/ceph/ceph_san.c:129:39: sparse: sparse: no newline at end of file
>> net/ceph/ceph_san.c:17:39: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct ceph_san_tls_logger * @@
net/ceph/ceph_san.c:17:39: sparse: expected void const [noderef] __percpu *__vpp_verify
net/ceph/ceph_san.c:17:39: sparse: got struct ceph_san_tls_logger *
vim +17 net/ceph/ceph_san.c
7
8 /* Use per-core TLS logger; no global list or lock needed */
9 DEFINE_PER_CPU(struct ceph_san_tls_logger, ceph_san_tls);
10 EXPORT_SYMBOL(ceph_san_tls);
11 /* The definitions for struct ceph_san_log_entry and struct ceph_san_tls_logger
12 * have been moved to cephsan.h (under CONFIG_DEBUG_FS) to avoid duplication.
13 */
14
15 char *get_log_cephsan(void) {
16 /* Use the per-core TLS logger */
> 17 struct ceph_san_tls_logger *tls = this_cpu_ptr(&ceph_san_tls);
18 int head_idx = tls->head_idx++ & (CEPH_SAN_MAX_LOGS - 1);
19 tls->logs[head_idx].pid = current->pid;
20 tls->logs[head_idx].ts = jiffies;
21 memcpy(tls->logs[head_idx].comm, current->comm, TASK_COMM_LEN);
22
23 return tls->logs[head_idx].buf;
24 }
25 EXPORT_SYMBOL(get_log_cephsan);
26
27 /* Cleanup function to free all TLS logger objects.
28 * Call this at module exit to free allocated TLS loggers.
29 */
30 void cephsan_cleanup(void)
31 {
32 }
33 EXPORT_SYMBOL(cephsan_cleanup);
34 /* Initialize the Ceph SAN logging infrastructure.
35 * Call this at module init to set up the global list and lock.
36 */
37 int cephsan_init(void)
38 {
39
40 return 0;
41 }
42 EXPORT_SYMBOL(cephsan_init);
43
44 /**
45 * cephsan_pagefrag_init - Initialize the pagefrag allocator.
46 *
47 * Allocates a 16KB contiguous buffer and resets head and tail pointers.
48 *
49 * Return: 0 on success, negative error code on failure.
50 */
51 int cephsan_pagefrag_init(struct cephsan_pagefrag *pf)
52 {
53 pf->buffer = kmalloc(CEPHSAN_PAGEFRAG_SIZE, GFP_KERNEL);
54 if (!pf->buffer)
55 return -ENOMEM;
56
57 pf->head = 0;
58 pf->tail = 0;
59 return 0;
60 }
61 EXPORT_SYMBOL(cephsan_pagefrag_init);
62
63 /**
64 * cephsan_pagefrag_alloc - Allocate bytes from the pagefrag buffer.
65 * @n: number of bytes to allocate.
66 *
67 * Allocates @n bytes if there is sufficient free space in the buffer.
68 * Advances the head pointer by @n bytes (wrapping around if needed).
69 *
70 * Return: pointer to the allocated memory, or NULL if not enough space.
71 */
72 u64 cephsan_pagefrag_alloc(struct cephsan_pagefrag *pf, unsigned int n)
73 {
74 unsigned int used, free_space, remaining;
75 void *ptr;
76
77 /* Compute usage in the circular buffer */
78 if (pf->head >= pf->tail)
79 used = pf->head - pf->tail;
80 else
81 used = CEPHSAN_PAGEFRAG_SIZE - pf->tail + pf->head;
82
83 free_space = CEPHSAN_PAGEFRAG_SIZE - used;
84 if (n > free_space)
85 return 0;
86
87 /* Check if allocation would wrap around buffer end */
88 if (pf->head + n > CEPHSAN_PAGEFRAG_SIZE) {
89 /* Calculate bytes remaining until buffer end */
90 remaining = CEPHSAN_PAGEFRAG_SIZE - pf->head;
91 /* Move tail to start if needed */
92 if (pf->tail < n - remaining)
93 pf->tail = 0;
94
95 /* Return pointer to new head at buffer start */
96 ptr = pf->buffer;
97 pf->head = n - remaining;
98 } else {
99 /* No wrap around needed */
100 ptr = (char *)pf->buffer + pf->head;
101 pf->head += n;
102 }
103 /* Return combined u64 with buffer index in lower 32 bits and size in upper 32 bits */
104 return ((u64)(n) << 32) | (ptr - pf->buffer);
105 }
106 EXPORT_SYMBOL(cephsan_pagefrag_alloc);
107 /**
108 * cephsan_pagefrag_free - Free bytes in the pagefrag allocator.
109 * @n: number of bytes to free.
110 *
111 * Advances the tail pointer by @n bytes (wrapping around if needed).
112 */
113 void cephsan_pagefrag_free(struct cephsan_pagefrag *pf, unsigned int n)
114 {
115 pf->tail = (pf->tail + n) % CEPHSAN_PAGEFRAG_SIZE;
116 }
117 EXPORT_SYMBOL(cephsan_pagefrag_free);
118 /**
119 * cephsan_pagefrag_deinit - Deinitialize the pagefrag allocator.
120 *
121 * Frees the allocated buffer and resets the head and tail pointers.
122 */
123 void cephsan_pagefrag_deinit(struct cephsan_pagefrag *pf)
124 {
125 kfree(pf->buffer);
126 pf->buffer = NULL;
127 pf->head = pf->tail = 0;
128 }
> 129 EXPORT_SYMBOL(cephsan_pagefrag_deinit);
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-02-13 16:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 16:32 [ceph-client:tls_logger 6/13] net/ceph/ceph_san.c:17:39: sparse: sparse: incorrect type in initializer (different address spaces) kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.