All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.duyck@gmail.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Alexander Duyck <alexander.h.duyck@redhat.com>,
	netdev@vger.kernel.org
Cc: davem@davemloft.net
Subject: Re: [net-next PATCH 5/9] fib_trie: Add tnode struct as a container for fields not needed in key_vector
Date: Fri, 06 Mar 2015 08:13:35 -0800	[thread overview]
Message-ID: <54F9D22F.3080701@gmail.com> (raw)
In-Reply-To: <54F9A8D7.4070304@cogentembedded.com>

On 03/06/2015 05:17 AM, Sergei Shtylyov wrote:
> Hello.
>
> On 3/6/2015 1:51 AM, Alexander Duyck wrote:
>
>> This change pulls the fields not explicitly needed in the key_vector and
>> placed them in the new tnode structure.  By doing this we will
>> eventually
>> be able to reduce the key_vector down to 16 bytes on 64 bit systems, and
>> 12 bytes on 32 bit systems.
>
>> Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
>> ---
>>   net/ipv4/fib_trie.c |   72
>> ++++++++++++++++++++++++++++-----------------------
>>   1 file changed, 39 insertions(+), 33 deletions(-)
>>
>> diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
>> index f06c92e..5e1c469 100644
>> --- a/net/ipv4/fib_trie.c
>> +++ b/net/ipv4/fib_trie.c
> [...]
>> @@ -316,48 +320,50 @@ static inline void empty_child_dec(struct
>> key_vector *n)
>>
>>   static struct key_vector *leaf_new(t_key key, struct fib_alias *fa)
>>   {
> [...]
>> +    struct tnode *kv = kmem_cache_alloc(trie_leaf_kmem, GFP_KERNEL);
>> +    struct key_vector *l = kv->kv;
>> +
>> +    if (!kv)
>
>    You dereference 'kv' before this check.
>
> [...]
>>   static struct key_vector *tnode_new(t_key key, int pos, int bits)
>>   {
>> -    struct key_vector *tn = tnode_alloc(bits);
>> +    struct tnode *tnode = tnode_alloc(bits);
>>       unsigned int shift = pos + bits;
>> +    struct key_vector *tn = tnode->kv;
>>
>>       /* verify bits and pos their msb bits clear and values are
>> valid */
>>       BUG_ON(!bits || (shift > KEYLENGTH));
>>
> [...]
>> +    pr_debug("AT %p s=%zu %zu\n", tnode, TNODE_SIZE(0),
>>            sizeof(struct key_vector *) << bits);
>> +
>> +    if (!tnode)
>
>    Likewise with 'tnode'.
>
> [...]
>
> WBR, Sergei

Actually neither of these are a deference.  The 'kv' member is an array
of size 1, so tnode->kv is actually just adding the offset of the array
to the pointer and storing it.  So if tnode is NULL, then tnode->kv is
NULL + 32 on a 64b system.  It isn't really a dereference until I use
the ->, *, or [] operators on the tn pointer.

- Alex

  reply	other threads:[~2015-03-06 16:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-05 22:50 [net-next PATCH 0/9] The rest of the FIB patches (add key_vector to fib_table) Alexander Duyck
2015-03-05 22:50 ` [net-next PATCH 1/9] fib_trie: Return pointer to tnode pointer in resize/inflate/halve Alexander Duyck
2015-03-05 22:50 ` [net-next PATCH 2/9] fib_trie: Rename tnode to key_vector Alexander Duyck
2015-03-05 22:50 ` [net-next PATCH 3/9] fib_trie: replace tnode_get_child functions with get_child macros Alexander Duyck
2015-03-05 22:50 ` [net-next PATCH 4/9] fib_trie: Rename tnode_child_length to child_length Alexander Duyck
2015-03-05 22:51 ` [net-next PATCH 5/9] fib_trie: Add tnode struct as a container for fields not needed in key_vector Alexander Duyck
2015-03-06 13:17   ` Sergei Shtylyov
2015-03-06 16:13     ` Alexander Duyck [this message]
2015-03-05 22:51 ` [net-next PATCH 6/9] fib_trie: Move rcu from key_vector to tnode, add accessors Alexander Duyck
2015-03-05 22:51 ` [net-next PATCH 7/9] fib_trie: Pull empty_children and full_children into tnode Alexander Duyck
2015-03-05 22:51 ` [net-next PATCH 8/9] fib_trie: Move parent from key_vector to tnode Alexander Duyck
2015-03-05 22:51 ` [net-next PATCH 9/9] fib_trie: Add key vector to root, return parent key_vector in resize 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=54F9D22F.3080701@gmail.com \
    --to=alexander.duyck@gmail.com \
    --cc=alexander.h.duyck@redhat.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    /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.