Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936578AbXHIOWV (ORCPT ); Thu, 9 Aug 2007 10:22:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S965183AbXHIOV7 (ORCPT ); Thu, 9 Aug 2007 10:21:59 -0400 Received: from ipsec.mad.optenet.com ([213.27.232.70]:41417 "EHLO mta-mad.optenet.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S964952AbXHIOV5 (ORCPT ); Thu, 9 Aug 2007 10:21:57 -0400 Subject: [PATCH 1/1] af_packet: don't enable timestamps in mmap'ed sockets From: Unai Uribarri To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Content-Type: text/plain Organization: Optenet Date: Thu, 09 Aug 2007 16:21:54 +0200 Message-Id: <1186669314.24669.56.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1752 Lines: 51 Hello folks, I've discovered two strange behaviours (bugs?) about timestamp generation: 1. If a program opens an AF_PACKET socket and setup a reception ring with setsockopt(sock, SOL_PACKET, PACKET_RX_RING), timestamps are automatically (re)enabled at the reception of every packet. 2. Setting SOL_SOCKET/SO_TIMESTAMP to 0 doesn't disables timestamp generation. Every skb continues begin timestamped until you close the socket that activated it. Timestamp generation is a heavy task that is consuming more than 50% of the CPU (using ACPI PM clock) and is currently the bottleneck in my packet capturing application. The attached patch removes the automatic timestamp activation, that only mmap'ed AF_PACKET sockets perform. I known it can break user applications, but I believe that it's the correct solution. I will be very pleased to receive any feedback. Signed-off-by: Unai Uribarri --- diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 1322d62..a4f2da3 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -640,10 +640,6 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe h->tp_snaplen = snaplen; h->tp_mac = macoff; h->tp_net = netoff; - if (skb->tstamp.tv64 == 0) { - __net_timestamp(skb); - sock_enable_timestamp(sk); - } tv = ktime_to_timeval(skb->tstamp); h->tp_sec = tv.tv_sec; h->tp_usec = tv.tv_usec; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/