On Apr 4, 2011, at 4:00 PM, 王勇 wrote: > Thank you, I checked it out and the kcalloc is disappeared. > BTW, what I am doing is to read packets from the ring inside the kernel and I > tried to do it with a new plugin, but the kernel crashed with "scheduling > while atomic" because my code will have to cause a rescheduling. I am now > trying to writing a new kernel thread to do it. In this kernel thread, I > borrowed the code of pfring_read() in userland/lib/pf_ring.c. Do you have > some suggestion? Hi as you're writing into the kernel, I think you can't borrow any userland code and recompile it.
Luca > > Thank you for your time. > > > > >> -----原始邮件----- >> 发件人: "Luca Deri" <[email protected]> >> 发送时间: 2011年4月4日 星期一 >> 收件人: "[email protected]" <[email protected]> >> 抄送: >> 主题: Re: [Ntop-misc] about "BUG: scheduling while atomic" >> >> Hi >> Please update from svn: this problem should already be fixed >> >> Luca >> >> >> >> On 04/apr/2011, at 12:33, 王勇 <[email protected]> wrote: >> >>> Dear all, >>> >>> I am a newbie to pf ring and kernel program. I added several lines follow >>> the calling of add_skb_to_ring in pf_ring/kernel/pf_ring.c to do something >>> extra I need. It looks like: >>> >>> >>> >>> from line 2556 fo kernel/pf_ring.c >>> >>> >>> >>> if((pfr != NULL) >>> && (pfr->ring_netdev != &none_dev) /* Not a dummy socket bound to >>> "none" */ >>> && (pfr->cluster_id == 0 /* No cluster */ ) >>> && (pfr->ring_slots != NULL) >>> && is_valid_skb_direction(pfr->direction, recv_packet) >>> && ((pfr->ring_netdev == skb->dev) >>> || (pfr->ring_netdev == &any_dev) /* Socket bound to 'any' */ >>> || ((skb->dev->flags & IFF_SLAVE) && (pfr->ring_netdev == >>> skb->dev->master)))) { >>> /* We've found the ring where the packet can be stored */ >>> int old_caplen = hdr.caplen; /* Keep old lenght */ >>> hdr.caplen = min(hdr.caplen, pfr->bucket_len); >>> add_skb_to_ring(skb, pfr, &hdr, is_ip_pkt, displ, channel_id, >>> num_rx_channels); >>> >>> my_function_here(skb); >>> hdr.caplen = old_caplen; >>> rc = 1; /* Ring found: we've done our job */ >>> } >>> >>> >>> >>> In my_function_here(), I just kmalloc some byte with GFP_KERNEL and the >>> kfree it. When I run this code, the kernel always crashes with message:BUG: >>> scheduling while atomic >>> >>> I think this is because kmalloc with GFP_KERNEL, but I noticed that in >>> add_skb_to_ring() there is kcalloc with GFP_KERNEL! Why this is safe and my >>> code cause kernel crash? >>> >>> >>> >>> Thank you for your time! >>> _______________________________________________ >>> Ntop-misc mailing list >>> [email protected] >>> http://listgateway.unipi.it/mailman/listinfo/ntop-misc >> _______________________________________________ >> Ntop-misc mailing list >> [email protected] >> http://listgateway.unipi.it/mailman/listinfo/ntop-misc > > _______________________________________________ > Ntop-misc mailing list > [email protected] > http://listgateway.unipi.it/mailman/listinfo/ntop-misc --- If you can not measure it, you can not improve it - Lord Kelvin _______________________________________________ Ntop-misc mailing list [email protected] http://listgateway.unipi.it/mailman/listinfo/ntop-misc
