af_packet.c flush_dcache_page

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linux Netdev List <netdev@...>
Date: Wednesday, October 31, 2007 - 10:08 am

I'm currently adding mmap support to af_netlink based on the
af_packet implementation and I'm wondering about this code in
tpacket_rcv():

         h->tp_status = status;
         smp_mb();

         {
                 struct page *p_start, *p_end;
                 u8 *h_end = (u8 *)h + macoff + snaplen - 1;

                 p_start = virt_to_page(h);
                 p_end = virt_to_page(h_end);
                 while (p_start <= p_end) {
                         flush_dcache_page(p_start);
                         p_start++;
                 }
         }

Shouldn't the flushing be done in reverse order to make sure
that the page containing tp_status is flushed last and userspace
doesn't start looking at following pages before all dcache entries
are flushed?

A related question: Documentation/cachetlb.txt mentions that
flushing also needs to be done for reading of shared+writable
mapped pages, so it seems like we also need to call flush_dcache_page 
before the tp_status check earlier in that function and packet_poll().
-
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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
af_packet.c flush_dcache_page, Patrick McHardy, (Wed Oct 31, 10:08 am)
Re: af_packet.c flush_dcache_page, David Miller, (Wed Oct 31, 6:57 pm)
Re: af_packet.c flush_dcache_page, Patrick McHardy, (Thu Nov 1, 12:10 pm)
Re: af_packet.c flush_dcache_page, Evgeniy Polyakov, (Thu Nov 1, 12:27 pm)