From patchwork Thu Apr 15 08:27:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Changli Gao X-Patchwork-Id: 50227 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 7CA3FB7080 for ; Thu, 15 Apr 2010 18:27:46 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757198Ab0DOI1m (ORCPT ); Thu, 15 Apr 2010 04:27:42 -0400 Received: from mail-gy0-f174.google.com ([209.85.160.174]:38391 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756053Ab0DOI1k convert rfc822-to-8bit (ORCPT ); Thu, 15 Apr 2010 04:27:40 -0400 Received: by gyg13 with SMTP id 13so616291gyg.19 for ; Thu, 15 Apr 2010 01:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:received:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=r6c7bH+Hfzv42BiXleae6AH0MTsBYGbsM8U47ot0jLM=; b=Vj3Cjup6RWxTdCzZ4EaurhW4Y+btJuALdmjkSitgawFjck4EEW9av9QBakE2MdVOGI H0e8MHY1uz/iaI+2Y+OFW7fXlKZcUXQamKovuOtjH4SUCA26ZgD1UiojkaWgoEb1s3+4 qeNgDSWtF2sNR13vZnB1eiDxRTP5TvfsFVk+Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=KwU+BnQwR+P5qZlXJPnxHiXL6ukvseqWmH1XIq8dgc2D4wRlrLDZAzQNlEy/0PsMoA 2fYZ5U7XVxqMyI8640W3ykDsTrj5ujj/Gih7DZyZEqwvWD1u/JYGu0bvTQ03xHVeuSl+ uH7tRDouK9oGVcIBlyjL3fn4xsdwT3ZMPSv94= MIME-Version: 1.0 Received: by 10.231.158.7 with HTTP; Thu, 15 Apr 2010 01:27:19 -0700 (PDT) In-Reply-To: <20100415.005726.205428265.davem@davemloft.net> References: <20100415.003711.159334670.davem@davemloft.net> <20100415.005726.205428265.davem@davemloft.net> From: Changli Gao Date: Thu, 15 Apr 2010 16:27:19 +0800 Received: by 10.101.170.38 with SMTP id x38mr9221227ano.101.1271320059383; Thu, 15 Apr 2010 01:27:39 -0700 (PDT) Message-ID: Subject: Re: BUG: using smp_processor_id() in preemptible [00000000] code: avahi-daemon: caller is netif_rx To: David Miller Cc: eric.dumazet@gmail.com, therbert@google.com, eparis@redhat.com, netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Apr 15, 2010 at 3:57 PM, David Miller wrote: > > Why?  If we are in an interrupt (either soft or hard) then > smp_processor_id() is stable, and valid. > > Changli, I find it very frustrating to communicate with you, you are > very terse in your descriptions and analysis and you make many simple > errors that would be avoided if you spent more time thinking about > things before sending your emails. :-/ > > Instead of just showing some pseudo patch, state WHY it is needed. > Talk about the execution state of environment and what rules or other > things are being violated which must be corrected. > Sorry. English isn't my native language, so sometimes I can't describe myself clearly. I think the following patch from Eric should be applied instead. As you know "netif_rx() must be invoked from a hardware or software interrupt, which implies preemption disabled.", obviously ip_dev_loopback_xmit() doesn't obey this rule, so the crash isn't the fault of net_rx(). If there are other users, who don't obey this rule, they should be fixed too. For this patch: - cpu = smp_processor_id(); + ret = enqueue_to_backlog(skb, get_cpu()); + put_cpu(); You said: " If we are in an interrupt (either soft or hard) then smp_processor_id() is stable, and valid.". so we don't need to call get_cpu() instead of smp_processor_id(). get_cpu() brings no good but additional cost preempt_disable(). diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index c65f18e..d1bcc9f 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -120,7 +120,7 @@ static int ip_dev_loopback_xmit(struct sk_buff *newskb) newskb->pkt_type = PACKET_LOOPBACK; newskb->ip_summed = CHECKSUM_UNNECESSARY; WARN_ON(!skb_dst(newskb)); - netif_rx(newskb); + netif_rx_ni(newskb); return 0; }