All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about arch/x86/xen/mmu.c
@ 2014-12-04 21:30 Jan-Simon Moeller
  2014-12-05  4:47 ` Jürgen Groß
  0 siblings, 1 reply; 2+ messages in thread
From: Jan-Simon Moeller @ 2014-12-04 21:30 UTC (permalink / raw)
  To: xen-devel

Hi !

My name is Jan-Simon Moeller and I'm looking into compiling the kernel with 
LLVM/Clang (see llvm.linuxfoundation.org) . 

Right now we face this issue when compiling with clang:

 CC      arch/x86/xen/mmu.o
arch/x86/xen/mmu.c:1343:18: error: fields must have a constant size:
     'variable length array in structure' extension will never be
     supported
               DECLARE_BITMAP(mask, num_processors);
                              ^
include/linux/types.h:10:16: note: expanded from macro 'DECLARE_BITMAP'
       unsigned long name[BITS_TO_LONGS(bits)]
                     ^
1 error generated.


Question to the experts: why can't we just use NR_CPUS and be done with it ?
NR_CPUS will be setup by CONFIG_NR_CPUS and thus static.
( e.g. arch/x86/configs/x86_64_defconfig:CONFIG_NR_CPUS=64 )


The code in question is:

static void xen_flush_tlb_others(const struct cpumask *cpus,
				 struct mm_struct *mm, unsigned long start,
				 unsigned long end)
{
	struct {
		struct mmuext_op op;
#ifdef CONFIG_SMP
		DECLARE_BITMAP(mask, num_processors);
#else
		DECLARE_BITMAP(mask, NR_CPUS);
#endif
	} *args;
	struct multicall_space mcs;

	trace_xen_mmu_flush_tlb_others(cpus, mm, start, end);

	if (cpumask_empty(cpus))
		return;		/* nothing to do */

	mcs = xen_mc_entry(sizeof(*args));
	args = mcs.args;
	args->op.arg2.vcpumask = to_cpumask(args->mask);

	/* Remove us, and any offline CPUS. */
	cpumask_and(to_cpumask(args->mask), cpus, cpu_online_mask);
	cpumask_clear_cpu(smp_processor_id(), to_cpumask(args->mask));

	args->op.cmd = MMUEXT_TLB_FLUSH_MULTI;
	if (end != TLB_FLUSH_ALL && (end - start) <= PAGE_SIZE) {
		args->op.cmd = MMUEXT_INVLPG_MULTI;
		args->op.arg1.linear_addr = start;
	}

	MULTI_mmuext_op(mcs.mc, &args->op, 1, NULL, DOMID_SELF);

	xen_mc_issue(PARAVIRT_LAZY_MMU);
}


Pointers:
http://www.slideshare.net/linaroorg/lcu14-209-llvm-linux-39165110  # slide 19
http://lwn.net/Articles/441018/
http://stackoverflow.com/questions/14629504/variable-length-array-in-the-middle-of-struct-why-this-c-code-is-valid-for-gcc




Thanks!

Jan-Simon

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question about arch/x86/xen/mmu.c
  2014-12-04 21:30 Question about arch/x86/xen/mmu.c Jan-Simon Moeller
@ 2014-12-05  4:47 ` Jürgen Groß
  0 siblings, 0 replies; 2+ messages in thread
From: Jürgen Groß @ 2014-12-05  4:47 UTC (permalink / raw)
  To: Jan-Simon Moeller, xen-devel

On 12/04/2014 10:30 PM, Jan-Simon Moeller wrote:
> Hi !
>
> My name is Jan-Simon Moeller and I'm looking into compiling the kernel with
> LLVM/Clang (see llvm.linuxfoundation.org) .
>
> Right now we face this issue when compiling with clang:
>
>   CC      arch/x86/xen/mmu.o
> arch/x86/xen/mmu.c:1343:18: error: fields must have a constant size:
>       'variable length array in structure' extension will never be
>       supported
>                 DECLARE_BITMAP(mask, num_processors);
>                                ^
> include/linux/types.h:10:16: note: expanded from macro 'DECLARE_BITMAP'
>         unsigned long name[BITS_TO_LONGS(bits)]
>                       ^
> 1 error generated.
>
>
> Question to the experts: why can't we just use NR_CPUS and be done with it ?
> NR_CPUS will be setup by CONFIG_NR_CPUS and thus static.
> ( e.g. arch/x86/configs/x86_64_defconfig:CONFIG_NR_CPUS=64 )

This would expand the structure on kernels configured for many cpus
(e.g. 4096) but running on a smaller machine dramatically.


Juergen

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-05  4:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-04 21:30 Question about arch/x86/xen/mmu.c Jan-Simon Moeller
2014-12-05  4:47 ` Jürgen Groß

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.