* [PATCH v3 1/2] RDS: fix "Kernel unaligned access" on sparc64
@ 2016-04-03 12:24 Shamir Rabinovitch
2016-04-03 12:24 ` [PATCH v3 2/2] RDS: fix congestion map corruption for PAGE_SIZE > 8k Shamir Rabinovitch
2016-04-04 19:57 ` [PATCH v3 1/2] RDS: fix "Kernel unaligned access" on sparc64 David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Shamir Rabinovitch @ 2016-04-03 12:24 UTC (permalink / raw)
To: rds-devel, netdev; +Cc: davem, shamir.rabinovitch
Sparc64 expect 64 bit types to be aligned to 8. This patch ensure that
memory allocated by 'rds_page_remainder_alloc' will be aligned to 8.
This patch fix issue found in 'rds_ib_cong_recv' when accessing
unaligned memory using uint64_t pointer.
Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
Reviewed-by: Wengang Wang <wen.gang.wang@oracle.com>
Reviewed-by: Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Tested-by: Anand Bibhuti <anand.bibhuti@oracle.com>
---
net/rds/page.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/rds/page.c b/net/rds/page.c
index 616f21f..4813e1f 100644
--- a/net/rds/page.c
+++ b/net/rds/page.c
@@ -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) {
__free_page(rem->r_page);
rem->r_page = NULL;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v3 2/2] RDS: fix congestion map corruption for PAGE_SIZE > 8k
2016-04-03 12:24 [PATCH v3 1/2] RDS: fix "Kernel unaligned access" on sparc64 Shamir Rabinovitch
@ 2016-04-03 12:24 ` Shamir Rabinovitch
2016-04-04 19:57 ` [PATCH v3 1/2] RDS: fix "Kernel unaligned access" on sparc64 David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Shamir Rabinovitch @ 2016-04-03 12:24 UTC (permalink / raw)
To: rds-devel, netdev; +Cc: davem, shamir.rabinovitch
On Sparc64 page size is 8k. So single page contain 2 RDS fragments. If
'rds_ib_cong_recv' ignore the RDS fragment offset in to the page it then
read the data fragment as far congestion map update and lead to
corruption of the RDS connection far congestion map.
This patch require the below patch for Sparc64 platforms:
001f8f8 RDS: fix "Kernel unaligned access" on sparc64
Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
Reviewed-by: Wengang Wang <wen.gang.wang@oracle.com>
Reviewed-by: Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Tested-by: Anand Bibhuti <anand.bibhuti@oracle.com>
---
net/rds/ib_recv.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 977fb86..abc8cc8 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -796,7 +796,7 @@ static void rds_ib_cong_recv(struct rds_connection *conn,
addr = kmap_atomic(sg_page(&frag->f_sg));
- src = addr + frag_off;
+ src = addr + frag->f_sg.offset + frag_off;
dst = (void *)map->m_page_addrs[map_page] + map_off;
for (k = 0; k < to_copy; k += 8) {
/* Record ports that became uncongested, ie
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3 1/2] RDS: fix "Kernel unaligned access" on sparc64
2016-04-03 12:24 [PATCH v3 1/2] RDS: fix "Kernel unaligned access" on sparc64 Shamir Rabinovitch
2016-04-03 12:24 ` [PATCH v3 2/2] RDS: fix congestion map corruption for PAGE_SIZE > 8k Shamir Rabinovitch
@ 2016-04-04 19:57 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-04-04 19:57 UTC (permalink / raw)
To: shamir.rabinovitch; +Cc: rds-devel, netdev
From: Shamir Rabinovitch <shamir.rabinovitch@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?!?!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-04 19:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-03 12:24 [PATCH v3 1/2] RDS: fix "Kernel unaligned access" on sparc64 Shamir Rabinovitch
2016-04-03 12:24 ` [PATCH v3 2/2] RDS: fix congestion map corruption for PAGE_SIZE > 8k Shamir Rabinovitch
2016-04-04 19:57 ` [PATCH v3 1/2] RDS: fix "Kernel unaligned access" on sparc64 David Miller
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).