From patchwork Tue Jun 16 01:10:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 484751 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9808E1400A0 for ; Tue, 16 Jun 2015 11:10:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=pUBVV71B; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754895AbbFPBKS (ORCPT ); Mon, 15 Jun 2015 21:10:18 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:36579 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753712AbbFPBKQ (ORCPT ); Mon, 15 Jun 2015 21:10:16 -0400 Received: by pabqy3 with SMTP id qy3so1754919pab.3; Mon, 15 Jun 2015 18:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:mime-version :content-transfer-encoding; bh=HhK+aqnGE1X9v2WQfssWMbXtQsuzkrdJXqeLaw+xzgE=; b=pUBVV71BhGv6i911lh2a68OTbF9xv7ay1AT3g5dRJwH7wm8UtOiq1kJKoRAcxOYVjR VevGeoc4PK4R4K96r1Z6aGAcisO4Oueyp0AvMpVUrvTFhPJCaED+Q3aQ/AEsVVcFP+kD rBnBlP4wxokrMCA3tMUo2l2or8zOSQAAkM4XK77ITC/4z7BVJelB6CGE0Pk4BTYB6Nba 3RSywmbiSSHEgBVEWdeIeU0B9L/bB1Q5odbbJFr1md6XkwL2E/aO9FAmEEsMSrJlCrez SOyGRO12WLxZUbJhoXAo6T7bYOjTklUwSFBUZu42j4jKNEOo3uWbB3fNnkifPVnf18xO pwVQ== X-Received: by 10.66.163.69 with SMTP id yg5mr52263801pab.150.1434417015754; Mon, 15 Jun 2015 18:10:15 -0700 (PDT) Received: from [172.30.42.71] (c-71-202-136-89.hsd1.ca.comcast.net. [71.202.136.89]) by mx.google.com with ESMTPSA id zb14sm13566235pab.20.2015.06.15.18.10.13 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Mon, 15 Jun 2015 18:10:14 -0700 (PDT) Message-ID: <1434417013.27504.161.camel@edumazet-glaptop2.roam.corp.google.com> Subject: [PATCH net-next] x_table: align per cpu xt_counter From: Eric Dumazet To: Pablo Neira Ayuso , David Miller Cc: netfilter-devel@vger.kernel.org, netdev , Florian Westphal Date: Mon, 15 Jun 2015 18:10:13 -0700 X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet Let's force a 16 bytes alignment on xt_counter percpu allocations, so that bytes and packets sit in same cache line. xt_counter being exported to user space, we cannot add __align(16) on the structure itself. Signed-off-by: Eric Dumazet Cc: Florian Westphal Acked-by: Florian Westphal --- include/linux/netfilter/x_tables.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 95693c4cebdda473a2f3e427dcc2511e83bf7405..1c97a2204379e14676ee33f0b15c5174b7afe680 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -356,7 +356,8 @@ static inline unsigned long ifname_compare_aligned(const char *_a, * so nothing needs to be done there. * * xt_percpu_counter_alloc returns the address of the percpu - * counter, or 0 on !SMP. + * counter, or 0 on !SMP. We force an alignment of 16 bytes + * so that bytes/packets share a common cache line. * * Hence caller must use IS_ERR_VALUE to check for error, this * allows us to return 0 for single core systems without forcing @@ -365,7 +366,8 @@ static inline unsigned long ifname_compare_aligned(const char *_a, static inline u64 xt_percpu_counter_alloc(void) { if (nr_cpu_ids > 1) { - void __percpu *res = alloc_percpu(struct xt_counters); + void __percpu *res = __alloc_percpu(sizeof(struct xt_counters), + sizeof(struct xt_counters)); if (res == NULL) return (u64) -ENOMEM;