From: Hideo AOKI <haoki@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David Miller <davem@davemloft.net>,
netdev <netdev@vger.kernel.org>,
Takahiro Yasui <tyasui@redhat.com>,
Masami Hiramatsu <mhiramat@redhat.com>,
Satoshi Oshima <satoshi.oshima.fk@hitachi.com>,
billfink@mindspring.com, Andi Kleen <andi@firstfloor.org>,
Evgeniy Polyakov <johnpol@2ka.mipt.ru>,
Stephen Hemminger <shemminger@linux-foundation.org>,
yoshfuji@linux-ipv6.org,
Yumiko Sugita <yumiko.sugita.yf@hitachi.com>
Subject: Re: [PATCH 2/4] [CORE]: datagram: mem_scheudle functions
Date: Sun, 16 Dec 2007 16:20:02 -0500 [thread overview]
Message-ID: <47659682.4030204@redhat.com> (raw)
In-Reply-To: <20071215153210.GA29415@gondor.apana.org.au>
Hello,
Thank you for your quick comments.
Herbert Xu wrote:
>> + spin_lock_irqsave(&sk->sk_lock.slock, flags);
>
> Please use bh_lock_sock since this must never be used from an
> IRQ handler.
I'll try to re-implement this locking mechanism as David suggested.
>> +static inline void sk_mem_reclaim(struct sock *sk)
>> +{
>> + if (sk->sk_type == SOCK_DGRAM)
>> + sk_datagram_mem_reclaim(sk);
>> +}
>
> Please get rid of these wrappers since we should only get here
> for datagram protocols.
In my understanding, TCP also uses ip_append_data() and
ip_ufo_append_data() via ip_send_reply(). Then I thought TCP could
reach datagram memory accounting functions, and I used the wrappers
since I didn't want to change TCP's sk_alloc_forward and
memory_allocated.
I'll try to remove these wrappers in next patch set. But I'd
appreciate it if you let me know whether we can keep the wrappers
in case TCP memory accounting doesn't work well due to accounting
in IP layer.
>> +static inline int sk_account_wmem_charge(struct sock *sk, int size)
>> +{
>> + unsigned long flags;
>> +
>> + /* account if protocol supports memory accounting. */
>> + if (!sk->sk_prot->memory_allocated || sk->sk_type != SOCK_DGRAM)
>> + return 1;
>> +
>> + spin_lock_irqsave(&sk->sk_lock.slock, flags);
>> + if (sk_datagram_wmem_schedule(sk, size)) {
>> + sk->sk_forward_alloc -= size;
>> + spin_unlock_irqrestore(&sk->sk_lock.slock, flags);
>> + return 1;
>> + }
>> + spin_unlock_irqrestore(&sk->sk_lock.slock, flags);
>> + return 0;
>> +}
>
> This is probably too big to inline.
>
>> +static inline int sk_account_rmem_charge(struct sock *sk, int size)
>> +{
>> + unsigned long flags;
>> +
>> + /* account if protocol supports memory accounting. */
>> + if (!sk->sk_prot->memory_allocated || sk->sk_type != SOCK_DGRAM)
>> + return 1;
>> +
>> + spin_lock_irqsave(&sk->sk_lock.slock, flags);
>> + if (sk_datagram_rmem_schedule(sk, size)) {
>> + sk->sk_forward_alloc -= size;
>> + spin_unlock_irqrestore(&sk->sk_lock.slock, flags);
>> + return 1;
>> + }
>> + spin_unlock_irqrestore(&sk->sk_lock.slock, flags);
>> + return 0;
>> +}
>
> Why are we duplicating the rmem/wmem versions when they're identical?
Good catch. I'll merge the body of these functions into one function.
Furthermore, I'll stop using inline if the code is large.
>> -int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
>> +int sock_queue_rcv_skb_with_owner(struct sock *sk, struct sk_buff *skb,
>> + void set_owner_r(struct sk_buff *nskb,
>> + struct sock* nsk))
>
> Just make a new function for this rather than playing with function
> pointers.
I understood. I'll fix it.
Again, many thanks for the review.
Regards,
Hideo
--
Hitachi Computer Products (America) Inc.
next prev parent reply other threads:[~2007-12-16 21:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-15 5:07 [PATCH 0/4] [UDP]: memory accounting and limitation (take 10) Hideo AOKI
2007-12-15 5:14 ` [PATCH 1/4] [UDP]: fix send buffer check Hideo AOKI
2007-12-15 5:15 ` [PATCH 2/4] [CORE]: datagram: mem_scheudle functions Hideo AOKI
2007-12-15 15:32 ` Herbert Xu
2007-12-16 21:20 ` Hideo AOKI [this message]
2007-12-15 5:15 ` [PATCH 3/4] [UDP]: add udp_mem, udp_rmem_min and udp_wmem_min Hideo AOKI
2007-12-15 5:15 ` [PATCH 4/4] [UDP]: memory accounting in IPv4 Hideo AOKI
2007-12-16 5:34 ` [PATCH 0/4] [UDP]: memory accounting and limitation (take 10) David Miller
2007-12-16 21:21 ` Hideo AOKI
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=47659682.4030204@redhat.com \
--to=haoki@redhat.com \
--cc=andi@firstfloor.org \
--cc=billfink@mindspring.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=johnpol@2ka.mipt.ru \
--cc=mhiramat@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=satoshi.oshima.fk@hitachi.com \
--cc=shemminger@linux-foundation.org \
--cc=tyasui@redhat.com \
--cc=yoshfuji@linux-ipv6.org \
--cc=yumiko.sugita.yf@hitachi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).