Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Feb 2018 18:19:14 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Jung-uk Kim <jkim@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r329340 - head/sys/amd64/include
Message-ID:  <20180216172320.I2471@besplex.bde.org>
In-Reply-To: <201802152042.w1FKgcDd079601@repo.freebsd.org>
References:  <201802152042.w1FKgcDd079601@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 15 Feb 2018, Jung-uk Kim wrote:

> Log:
>  Change size of padding to reflect reality.  No functional change.
>
>  Discussed with:		kib
>
> Modified:
>  head/sys/amd64/include/pcpu.h
>
> Modified: head/sys/amd64/include/pcpu.h
> ==============================================================================
> --- head/sys/amd64/include/pcpu.h	Thu Feb 15 19:49:15 2018	(r329339)
> +++ head/sys/amd64/include/pcpu.h	Thu Feb 15 20:42:38 2018	(r329340)
> @@ -75,7 +75,7 @@
> 	uint32_t pc_pcid_gen;						\
> 	uint32_t pc_smp_tlb_done;	/* TLB op acknowledgement */	\
> 	uint32_t pc_ibpb_set;						\
> -	char	__pad[216]		/* be divisor of PAGE_SIZE	\
> +	char	__pad[224]		/* be divisor of PAGE_SIZE	\
> 					   after cache alignment */

This still has a bogus struct member name.  The prefix for names in this
struct is pc_, not __.  Names beginning with __ are reserved for the
implementation.  The implementation might define __pad as <syntax error>.
To detect this common naming error.  It is also used in sys/efi.h.
i386/include/pcpu.h and i386/include/pmc_mdep.h.

The object of "be" in the comment is unclear.  It is the size of the
whole struct, not the MD fields.

The padding amount is especially odd for i386 pcpu.  It is 445 chars
there.  This means 445 chars of padding in __pad[] and 3 more chars
in unnamed padding.  The MD fields have no special alignment, and the
padding depends on the MI fields too.

With this change, on amd64 sizeof(struct pcpu) is 1K.  This indeed divides
PAGE_SIZE.  I don't see what good this does.  __pcpu is only aligned to
an 0x200 boundary in my test kernel (struct pcpu is aligned to an 0x40
boundary, and aligning to this boundary is what made the old padding work).

On i386, the garbage value of 445 also gives sizeof(struct pcpu) = 1K.
__pcpu is only aligned to an 0x80 boundary in my test kernel (struct pcpu
has the same CACHE_LINE_SIZE = 0x40 boundary as on amd64).

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180216172320.I2471>