From: kernel test robot <lkp@intel.com>
To: Alex Markuze <amarkuze@redhat.com>
Cc: oe-kbuild-all@lists.linux.dev, ceph-devel@vger.kernel.org
Subject: [ceph-client:tls_logger 4/5] net/ceph/ceph_san.c:46 ceph_san_tls_release() warn: inconsistent indenting
Date: Mon, 3 Mar 2025 01:31:26 +0800 [thread overview]
Message-ID: <202503030155.aCLWiEGC-lkp@intel.com> (raw)
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@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503030155.aCLWiEGC-lkp@intel.com/
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
reply other threads:[~2025-03-02 17:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202503030155.aCLWiEGC-lkp@intel.com \
--to=lkp@intel.com \
--cc=amarkuze@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).