All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.h.duyck@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, netdev@vger.kernel.org, davem@davemloft.net,
	Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [net-next PATCH 1/6] net: Add skb_free_frag to replace use of put_page in freeing skb->head
Date: Wed, 06 May 2015 13:55:37 -0700	[thread overview]
Message-ID: <554A7FC9.5010506@redhat.com> (raw)
In-Reply-To: <20150506134102.b01faad32e07ff3d308e1a09@linux-foundation.org>



On 05/06/2015 01:41 PM, Andrew Morton wrote:
> On Wed, 06 May 2015 13:27:43 -0700 Alexander Duyck <alexander.h.duyck@redhat.com> wrote:
>
>>>> +void skb_free_frag(void *head)
>>>> +{
>>>> +	struct page *page = virt_to_head_page(head);
>>>> +
>>>> +	if (unlikely(put_page_testzero(page))) {
>>>> +		if (likely(PageHead(page)))
>>>> +			__free_pages_ok(page, compound_order(page));
>>>> +		else
>>>> +			free_hot_cold_page(page, false);
>>>> +	}
>>>> +}
>>> Why are we testing for PageHead in here?  If the code were to simply do
>>>
>>> 	if (unlikely(put_page_testzero(page)))
>>> 		__free_pages_ok(page, compound_order(page));
>>>
>>> that would still work?
>> My assumption was that there was a performance difference between
>> __free_pages_ok and free_hot_cold_page for order 0 pages.  From what I
>> can tell free_hot_cold_page will do bulk cleanup via free_pcppages_bulk
>> while __free_pages_ok just calls free_one_page.
> Could be.  Plus there's hopefully some performance advantage if the
> page is genuinely cache-hot.  I don't think that anyone has verified
> the benefits of the hot/cold optimisation in the last decade or two,
> and it was always pretty marginal..

Either way it doesn't make much difference.  If you would prefer I can 
probably just call __free_pages_ok for all cases.

> Is the PageHead thing really "likely"?  We're usually dealing with
> order>0 pages here?

On any system that only supports 4K pages the default is to allocate an 
order 3 page (32K) and then pull the fragments out of that.  So if 
__free_pages_ok works for an order 0 page I'll just call it since it 
shouldn't be a very common occurrence anyway unless we are under memory 
pressure.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Alexander Duyck <alexander.h.duyck@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, netdev@vger.kernel.org, davem@davemloft.net,
	Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [net-next PATCH 1/6] net: Add skb_free_frag to replace use of put_page in freeing skb->head
Date: Wed, 06 May 2015 13:55:37 -0700	[thread overview]
Message-ID: <554A7FC9.5010506@redhat.com> (raw)
In-Reply-To: <20150506134102.b01faad32e07ff3d308e1a09@linux-foundation.org>



On 05/06/2015 01:41 PM, Andrew Morton wrote:
> On Wed, 06 May 2015 13:27:43 -0700 Alexander Duyck <alexander.h.duyck@redhat.com> wrote:
>
>>>> +void skb_free_frag(void *head)
>>>> +{
>>>> +	struct page *page = virt_to_head_page(head);
>>>> +
>>>> +	if (unlikely(put_page_testzero(page))) {
>>>> +		if (likely(PageHead(page)))
>>>> +			__free_pages_ok(page, compound_order(page));
>>>> +		else
>>>> +			free_hot_cold_page(page, false);
>>>> +	}
>>>> +}
>>> Why are we testing for PageHead in here?  If the code were to simply do
>>>
>>> 	if (unlikely(put_page_testzero(page)))
>>> 		__free_pages_ok(page, compound_order(page));
>>>
>>> that would still work?
>> My assumption was that there was a performance difference between
>> __free_pages_ok and free_hot_cold_page for order 0 pages.  From what I
>> can tell free_hot_cold_page will do bulk cleanup via free_pcppages_bulk
>> while __free_pages_ok just calls free_one_page.
> Could be.  Plus there's hopefully some performance advantage if the
> page is genuinely cache-hot.  I don't think that anyone has verified
> the benefits of the hot/cold optimisation in the last decade or two,
> and it was always pretty marginal..

Either way it doesn't make much difference.  If you would prefer I can 
probably just call __free_pages_ok for all cases.

> Is the PageHead thing really "likely"?  We're usually dealing with
> order>0 pages here?

On any system that only supports 4K pages the default is to allocate an 
order 3 page (32K) and then pull the fragments out of that.  So if 
__free_pages_ok works for an order 0 page I'll just call it since it 
shouldn't be a very common occurrence anyway unless we are under memory 
pressure.

  reply	other threads:[~2015-05-06 20:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-04 23:14 [net-next PATCH 0/6] Add skb_free_frag to replace put_page(virt_to_head_page(ptr)) Alexander Duyck
2015-05-04 23:14 ` Alexander Duyck
2015-05-04 23:14 ` [net-next PATCH 1/6] net: Add skb_free_frag to replace use of put_page in freeing skb->head Alexander Duyck
2015-05-04 23:14   ` Alexander Duyck
2015-05-05  0:16   ` Eric Dumazet
2015-05-05  0:16     ` Eric Dumazet
2015-05-05  2:49     ` Alexander Duyck
2015-05-06 19:38   ` Andrew Morton
2015-05-06 19:38     ` Andrew Morton
2015-05-06 20:27     ` Alexander Duyck
2015-05-06 20:27       ` Alexander Duyck
2015-05-06 20:41       ` Andrew Morton
2015-05-06 20:41         ` Andrew Morton
2015-05-06 20:55         ` Alexander Duyck [this message]
2015-05-06 20:55           ` Alexander Duyck
2015-05-04 23:14 ` [net-next PATCH 2/6] netcp: Replace put_page(virt_to_head_page(ptr)) w/ skb_free_frag Alexander Duyck
2015-05-04 23:14   ` Alexander Duyck
2015-05-04 23:14 ` [net-next PATCH 3/6] mvneta: " Alexander Duyck
2015-05-04 23:15 ` [net-next PATCH 4/6] e1000: Replace e1000_free_frag with skb_free_frag Alexander Duyck
2015-05-04 23:15   ` Alexander Duyck
2015-05-05  0:28   ` Jeff Kirsher
2015-05-04 23:15 ` [net-next PATCH 5/6] hisilicon: Replace put_page(virt_to_head_page()) with skb_free_frag() Alexander Duyck
2015-05-04 23:15   ` Alexander Duyck
2015-05-04 23:15 ` [net-next PATCH 6/6] bnx2x, tg3: " Alexander Duyck
2015-05-04 23:15   ` Alexander Duyck
2015-05-05 23:28 ` [net-next PATCH 0/6] Add skb_free_frag to replace put_page(virt_to_head_page(ptr)) David Miller
2015-05-05 23:28   ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2015-05-04 23:09 [net-next PATCH 1/6] net: Add skb_free_frag to replace use of put_page in freeing skb->head Alexander Duyck
2015-05-04 23:09 ` Alexander Duyck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=554A7FC9.5010506@redhat.com \
    --to=alexander.h.duyck@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.