[rds-devel] [PATCH v3 1/2] RDS: fix "Kernel unaligned access" on sparc64

David Miller davem at davemloft.net
Mon Apr 4 12:57:46 PDT 2016


From: Shamir Rabinovitch <shamir.rabinovitch at oracle.com>
Date: Sun,  3 Apr 2016 08:24:03 -0400

> @@ -135,8 +135,9 @@ int rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes,
>  			if (rem->r_offset != 0)
>  				rds_stats_inc(s_page_remainder_hit);
>  
> -			rem->r_offset += bytes;
> -			if (rem->r_offset == PAGE_SIZE) {
> +			/* fix 'Kernel unaligned access' on sparc64 */
> +			rem->r_offset += ALIGN(bytes, 8);
> +			if (rem->r_offset >= PAGE_SIZE) {

It is inappropriate to mark things with a comment like this in code
that has nothing at all to do what a specific architecture.

64-bit alignment, and this requirement, is also not sparc64 specific.
Other architectures have the same issue.

Next, comments should aide in the understanding of what the code is
trying to accomplish, when necessary.  So, something more appropriate
would be:

	/* Objects in this memory can countain 64-bit integers, align
	 * in order to accomodate that.
	 */

But it's very close to obvious here what the code is doing, and why
it might be doing so.

So I'd so no comment at all works best here.

I'm sorry, but it's a real pet peeve of mine when people mention
totally irrelevant crap in code comments.  What the heck does sparc64
have to do with aligning memory properly for the data types you will
be storing in that memory?!?!





More information about the rds-devel mailing list