tree: https://github.com/ceph/ceph-client.git tls_logger head: b980c3ea5fcc54aa543fd5e96212b7fb892d42a5 commit: 284eb81c9d23609f54d9e015ce2c40076e8d8a87 [4/5] TLS logger config: sparc-randconfig-r071-20250302 (https://download.01.org/0day-ci/archive/20250303/202503030155.aCLWiEGC-lkp@xxxxxxxxx/config) compiler: sparc-linux-gcc (GCC) 14.2.0 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@xxxxxxxxx> | Closes: https://lore.kernel.org/oe-kbuild-all/202503030155.aCLWiEGC-lkp@xxxxxxxxx/ New smatch warnings: net/ceph/ceph_san.c:46 ceph_san_tls_release() warn: inconsistent indenting net/ceph/ceph_san.c:71 get_cephsan_context() warn: inconsistent indenting net/ceph/ceph_san.c:120 log_cephsan_tls() warn: inconsistent indenting net/ceph/ceph_san.c:393 cephsan_pagefrag_deinit() warn: inconsistent indenting Old smatch warnings: net/ceph/ceph_san.c:56 ceph_san_tls_release() warn: inconsistent indenting net/ceph/ceph_san.c:123 log_cephsan_tls() warn: inconsistent indenting vim +46 net/ceph/ceph_san.c 26 27 static inline void *cephsan_pagefrag_get_ptr(struct cephsan_pagefrag *pf, u64 val); 28 /* The definitions for struct ceph_san_log_entry and struct ceph_san_tls_logger 29 * have been moved to cephsan.h (under CONFIG_DEBUG_FS) to avoid duplication. 30 */ 31 32 33 /* Release function for TLS storage */ 34 static void ceph_san_tls_release(void *ptr) 35 { 36 struct tls_ceph_san_context *context = ptr; 37 if (!context) 38 return; 39 40 /* Remove from global list with lock protection */ 41 spin_lock(&g_ceph_san_contexts_lock); 42 list_del(&context->list); 43 spin_unlock(&g_ceph_san_contexts_lock); 44 45 /* Free all log entries */ > 46 int head_idx = context->logger.head_idx & (CEPH_SAN_MAX_LOGS - 1); 47 int tail_idx = (head_idx + 1) & (CEPH_SAN_MAX_LOGS - 1); 48 49 for (int i = tail_idx; (i & (CEPH_SAN_MAX_LOGS - 1)) != head_idx; i++) { 50 struct ceph_san_log_entry_tls *entry = &context->logger.logs[i & (CEPH_SAN_MAX_LOGS - 1)]; 51 if (entry->buf) { 52 if (entry->ts & 0x1) 53 kmem_cache_free(ceph_san_log_256_cache, entry->buf); 54 else 55 kmem_cache_free(ceph_san_log_128_cache, entry->buf); 56 entry->buf = NULL; 57 } 58 } 59 60 kmem_cache_free(ceph_san_tls_logger_cache, context); 61 } 62 63 static struct tls_ceph_san_context *get_cephsan_context(void) { 64 struct tls_ceph_san_context *context; 65 66 context = current->tls.state; 67 if (context) 68 return context; 69 70 context = kmem_cache_alloc(ceph_san_tls_logger_cache, GFP_KERNEL); > 71 if (!context) 72 return NULL; 73 74 context->logger.pid = current->pid; 75 memcpy(context->logger.comm, current->comm, TASK_COMM_LEN); 76 77 /* Initialize list entry */ 78 INIT_LIST_HEAD(&context->list); 79 80 /* Add to global list with lock protection */ 81 spin_lock(&g_ceph_san_contexts_lock); 82 list_add(&context->list, &g_ceph_san_contexts); 83 spin_unlock(&g_ceph_san_contexts_lock); 84 85 current->tls.state = context; 86 current->tls.release = ceph_san_tls_release; 87 return context; 88 } 89 90 void log_cephsan_tls(char *buf) { 91 /* Use the task's TLS storage */ 92 int len = strlen(buf); 93 struct tls_ceph_san_context *ctx; 94 struct ceph_san_tls_logger *logger; 95 char *new_buf; 96 97 ctx = get_cephsan_context(); 98 if (!ctx) 99 return; 100 101 logger = &ctx->logger; 102 103 /* Log the message */ 104 int head_idx = logger->head_idx + 1 & (CEPH_SAN_MAX_LOGS - 1); 105 struct ceph_san_log_entry_tls *entry = &logger->logs[head_idx]; 106 107 /* Only free and reallocate if sizes differ */ 108 if (!entry->buf || (entry->ts & 0x1) != (len > LOG_BUF_SMALL)) { 109 if (entry->buf) { 110 if (entry->ts & 0x1) 111 kmem_cache_free(ceph_san_log_256_cache, entry->buf); 112 else 113 kmem_cache_free(ceph_san_log_128_cache, entry->buf); 114 entry->buf = NULL; 115 } 116 117 /* Allocate new buffer from appropriate cache */ 118 if (len <= LOG_BUF_SMALL) { 119 new_buf = kmem_cache_alloc(ceph_san_log_128_cache, GFP_KERNEL); > 120 entry->ts = jiffies | 0x0; 121 } else { 122 new_buf = kmem_cache_alloc(ceph_san_log_256_cache, GFP_KERNEL); 123 entry->ts = jiffies | 0x1; 124 } 125 } else { 126 /* Reuse existing buffer since size category hasn't changed */ 127 new_buf = entry->buf; 128 } 129 130 if (!new_buf) 131 return; 132 133 buf[len-1] = '\0'; 134 entry->buf = new_buf; 135 memcpy(entry->buf, buf, len); 136 137 logger->head_idx = head_idx; 138 } 139 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki