Mailing List Archive

ring_alloc_mem() in pf_ring kernel module
Hi Luca,

I was looking at the code in pfring kernel module function ring_alloc_mem()
to see how the module param min_num_slots impacts on the amount of memory
allocated for the ring.
I am wondering what the highlighted line below is doing. What alignment is
it looking to achieve? (it was added in revision 4400).

/* Alignment necessary on ARM platforms */
num_pages = tot_mem / PAGE_SIZE;
num_pages += (num_pages + (SHMLBA-1)) % SHMLBA;

On x86, SHMLBA is defined as PAGE_SIZE. On ARM SHMLBA it is defined as (4 *
PAGE_SIZE)

Regards
Jonathan
Re: ring_alloc_mem() in pf_ring kernel module [ In reply to ]
2011/5/10 Lynch, Jonathan <jonathan.lynch@thenowfactory.com>

> Hi Luca,
>
> I was looking at the code in pfring kernel module function ring_alloc_mem()
> to see how the module param min_num_slots impacts on the amount of memory
> allocated for the ring.
> I am wondering what the highlighted line below is doing. What alignment is
> it looking to achieve? (it was added in revision 4400).
>
> /* Alignment necessary on ARM platforms */
> num_pages = tot_mem / PAGE_SIZE;
> num_pages += (num_pages + (SHMLBA-1)) % SHMLBA;
>
> On x86, SHMLBA is defined as PAGE_SIZE. On ARM SHMLBA it is defined as (4
> * PAGE_SIZE)
>

SHMLBA is a multiple needed in some architectures with virtually indexed L1
caches, which suffer from aliasing problems, to make virtual aliases
coherent

Best Regards
Alfredo
Re: ring_alloc_mem() in pf_ring kernel module [ In reply to ]
Is this something that could be put inside a ARCH define and just set for
the relevant architectures?

Does this functionality added to vmalloc_user() in kernel 2.6.32 provide the
alignment necessary?
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2dca6999eed58d44b67e9de7d6ec230f6250553d

On 10 May 2011 17:27, Alfredo Cardigliano <cardigliano@ntop.org> wrote:

>
> 2011/5/10 Lynch, Jonathan <jonathan.lynch@thenowfactory.com>
>
> Hi Luca,
>>
>> I was looking at the code in pfring kernel module function
>> ring_alloc_mem() to see how the module param min_num_slots impacts on the
>> amount of memory allocated for the ring.
>> I am wondering what the highlighted line below is doing. What alignment is
>> it looking to achieve? (it was added in revision 4400).
>>
>> /* Alignment necessary on ARM platforms */
>> num_pages = tot_mem / PAGE_SIZE;
>> num_pages += (num_pages + (SHMLBA-1)) % SHMLBA;
>>
>> On x86, SHMLBA is defined as PAGE_SIZE. On ARM SHMLBA it is defined as (4
>> * PAGE_SIZE)
>>
>
> SHMLBA is a multiple needed in some architectures with virtually indexed L1
> caches, which suffer from aliasing problems, to make virtual aliases
> coherent
>
> Best Regards
> Alfredo
>
>
> _______________________________________________
> Ntop-misc mailing list
> Ntop-misc@listgateway.unipi.it
> http://listgateway.unipi.it/mailman/listinfo/ntop-misc
>
>
Re: ring_alloc_mem() in pf_ring kernel module [ In reply to ]
Jonathan
As you said SHMLBA is defined as PAGE_SIZE on x86 platforms, so you should
not worry about that.
Anyway, there was an error computing the memory size, but we fixed it today.
Check it out.

Best regards
Alfredo

2011/5/11 Lynch, Jonathan <jonathan.lynch@thenowfactory.com>

> Is this something that could be put inside a ARCH define and just set for
> the relevant architectures?
>
> Does this functionality added to vmalloc_user() in kernel 2.6.32 provide
> the alignment necessary?
>
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2dca6999eed58d44b67e9de7d6ec230f6250553d
>
> On 10 May 2011 17:27, Alfredo Cardigliano <cardigliano@ntop.org> wrote:
>
>>
>> 2011/5/10 Lynch, Jonathan <jonathan.lynch@thenowfactory.com>
>>
>> Hi Luca,
>>>
>>> I was looking at the code in pfring kernel module function
>>> ring_alloc_mem() to see how the module param min_num_slots impacts on the
>>> amount of memory allocated for the ring.
>>> I am wondering what the highlighted line below is doing. What alignment
>>> is it looking to achieve? (it was added in revision 4400).
>>>
>>> /* Alignment necessary on ARM platforms */
>>> num_pages = tot_mem / PAGE_SIZE;
>>> num_pages += (num_pages + (SHMLBA-1)) % SHMLBA;
>>>
>>> On x86, SHMLBA is defined as PAGE_SIZE. On ARM SHMLBA it is defined as
>>> (4 * PAGE_SIZE)
>>>
>>
>> SHMLBA is a multiple needed in some architectures with virtually indexed
>> L1 caches, which suffer from aliasing problems, to make virtual aliases
>> coherent
>>
>> Best Regards
>> Alfredo
>>
>>
>> _______________________________________________
>> Ntop-misc mailing list
>> Ntop-misc@listgateway.unipi.it
>> http://listgateway.unipi.it/mailman/listinfo/ntop-misc
>>
>>
>
> _______________________________________________
> Ntop-misc mailing list
> Ntop-misc@listgateway.unipi.it
> http://listgateway.unipi.it/mailman/listinfo/ntop-misc
>
>