* [linux-next:master 6345/7161] ipc/util.c:226:13: note: in expansion of macro 'max'
@ 2019-04-12 18:43 kbuild test robot
2019-04-14 18:21 ` Manfred Spraul
0 siblings, 1 reply; 3+ messages in thread
From: kbuild test robot @ 2019-04-12 18:43 UTC (permalink / raw)
To: Manfred Spraul; +Cc: kbuild-all, Andrew Morton, Linux Memory Management List
[-- Attachment #1: Type: text/plain, Size: 3849 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: bcb67f0fbce97425c5fae5109ffc44c5ddaf96ba
commit: 9b9607c0c01d45bbb0011bad9c6fefe4ab9df1d2 [6345/7161] ipc: do cyclic id allocation for the ipc object.
config: m68k-amcore_defconfig (attached as .config)
compiler: m68k-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 9b9607c0c01d45bbb0011bad9c6fefe4ab9df1d2
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=m68k
All warnings (new ones prefixed by >>):
In file included from include/asm-generic/bug.h:18:0,
from arch/m68k/include/asm/bug.h:32,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from ipc/util.c:47:
ipc/util.c: In function 'ipc_idr_alloc':
include/linux/kernel.h:828:29: warning: comparison of distinct pointer types lacks a cast
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
^
include/linux/kernel.h:842:4: note: in expansion of macro '__typecheck'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~
include/linux/kernel.h:852:24: note: in expansion of macro '__safe_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~
include/linux/kernel.h:868:19: note: in expansion of macro '__careful_cmp'
#define max(x, y) __careful_cmp(x, y, >)
^~~~~~~~~~~~~
>> ipc/util.c:226:13: note: in expansion of macro 'max'
max_idx = max(ids->in_use*3/2, ipc_min_cycle);
^~~
vim +/max +226 ipc/util.c
210
211 /*
212 * As soon as a new object is inserted into the idr,
213 * ipc_obtain_object_idr() or ipc_obtain_object_check() can find it,
214 * and the lockless preparations for ipc operations can start.
215 * This means especially: permission checks, audit calls, allocation
216 * of undo structures, ...
217 *
218 * Thus the object must be fully initialized, and if something fails,
219 * then the full tear-down sequence must be followed.
220 * (i.e.: set new->deleted, reduce refcount, call_rcu())
221 */
222
223 if (next_id < 0) { /* !CHECKPOINT_RESTORE or next_id is unset */
224 int max_idx;
225
> 226 max_idx = max(ids->in_use*3/2, ipc_min_cycle);
227 max_idx = min(max_idx, ipc_mni);
228
229 /* allocate the idx, with a NULL struct kern_ipc_perm */
230 idx = idr_alloc_cyclic(&ids->ipcs_idr, NULL, 0, max_idx,
231 GFP_NOWAIT);
232
233 if (idx >= 0) {
234 /*
235 * idx got allocated successfully.
236 * Now calculate the sequence number and set the
237 * pointer for real.
238 */
239 if (idx <= ids->last_idx) {
240 ids->seq++;
241 if (ids->seq >= ipcid_seq_max())
242 ids->seq = 0;
243 }
244 ids->last_idx = idx;
245
246 new->seq = ids->seq;
247 /* no need for smp_wmb(), this is done
248 * inside idr_replace, as part of
249 * rcu_assign_pointer
250 */
251 idr_replace(&ids->ipcs_idr, new, idx);
252 }
253 } else {
254 new->seq = ipcid_to_seqx(next_id);
255 idx = idr_alloc(&ids->ipcs_idr, new, ipcid_to_idx(next_id),
256 0, GFP_NOWAIT);
257 }
258 if (idx >= 0)
259 new->id = (new->seq << ipcmni_seq_shift()) + idx;
260 return idx;
261 }
262
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 9280 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [linux-next:master 6345/7161] ipc/util.c:226:13: note: in expansion of macro 'max'
2019-04-12 18:43 [linux-next:master 6345/7161] ipc/util.c:226:13: note: in expansion of macro 'max' kbuild test robot
@ 2019-04-14 18:21 ` Manfred Spraul
2019-04-15 20:57 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Manfred Spraul @ 2019-04-14 18:21 UTC (permalink / raw)
To: kbuild test robot
Cc: kbuild-all, Andrew Morton, Linux Memory Management List,
Waiman Long, Davidlohr Bueso
Hi,
Sorry - it seem that I forgot to retest the patch without sysctl() after
converting from direct if/else to max().
On 4/12/19 8:43 PM, kbuild test robot wrote:
> [...]
> ipc/util.c: In function 'ipc_idr_alloc':
> include/linux/kernel.h:828:29: warning: comparison of distinct pointer types lacks a cast
> (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> ^
> include/linux/kernel.h:842:4: note: in expansion of macro '__typecheck'
> (__typecheck(x, y) && __no_side_effects(x, y))
> ^~~~~~~~~~~
> include/linux/kernel.h:852:24: note: in expansion of macro '__safe_cmp'
> __builtin_choose_expr(__safe_cmp(x, y), \
> ^~~~~~~~~~
> include/linux/kernel.h:868:19: note: in expansion of macro '__careful_cmp'
> #define max(x, y) __careful_cmp(x, y, >)
> ^~~~~~~~~~~~~
>>> ipc/util.c:226:13: note: in expansion of macro 'max'
> max_idx = max(ids->in_use*3/2, ipc_min_cycle);
> ^~~
>
> 223 if (next_id < 0) { /* !CHECKPOINT_RESTORE or next_id is unset */
> 224 int max_idx;
> 225
> > 226 max_idx = max(ids->in_use*3/2, ipc_min_cycle);
With sysctl disabled, ipc_min_cycle is RADIX_TREE_MAP_SIZE, and this is
> include/linux/radix-tree.h:#define RADIX_TREE_MAP_SIZE (1UL <<
RADIX_TREE_MAP_SHIFT)
The checker behind max() is not smart enough to notice that
RADIX_TREE_MAP_SIZE can be represented as int without an overflow.
What is the right approach?
> #define ipc_min_cycle ({ int tmp; tmp = RADIX_TREE_MAP_SIZE; tmp;})
--
Manfred
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [linux-next:master 6345/7161] ipc/util.c:226:13: note: in expansion of macro 'max'
2019-04-14 18:21 ` Manfred Spraul
@ 2019-04-15 20:57 ` Andrew Morton
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2019-04-15 20:57 UTC (permalink / raw)
To: Manfred Spraul
Cc: kbuild test robot, kbuild-all, Linux Memory Management List,
Waiman Long, Davidlohr Bueso
On Sun, 14 Apr 2019 20:21:30 +0200 Manfred Spraul <manfred@colorfullife.com> wrote:
>
> With sysctl disabled, ipc_min_cycle is RADIX_TREE_MAP_SIZE, and this is
>
> > include/linux/radix-tree.h:#define RADIX_TREE_MAP_SIZE (1UL <<
> RADIX_TREE_MAP_SHIFT)
>
> The checker behind max() is not smart enough to notice that
> RADIX_TREE_MAP_SIZE can be represented as int without an overflow.
>
>
> What is the right approach?
>
Make ipc_min_cycle have the same type in both cases?
--- a/ipc/util.h~ipc-do-cyclic-id-allocation-for-the-ipc-object-fix
+++ a/ipc/util.h
@@ -42,7 +42,7 @@ extern int ipc_min_cycle;
#else /* CONFIG_SYSVIPC_SYSCTL */
#define ipc_mni IPCMNI
-#define ipc_min_cycle RADIX_TREE_MAP_SIZE
+#define ipc_min_cycle ((int)RADIX_TREE_MAP_SIZE)
#define ipcmni_seq_shift() IPCMNI_SHIFT
#define IPCMNI_IDX_MASK ((1 << IPCMNI_SHIFT) - 1)
#endif /* CONFIG_SYSVIPC_SYSCTL */
_
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-15 20:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 18:43 [linux-next:master 6345/7161] ipc/util.c:226:13: note: in expansion of macro 'max' kbuild test robot
2019-04-14 18:21 ` Manfred Spraul
2019-04-15 20:57 ` Andrew Morton
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).