diff options
author | Hideo Aoki <haoki@redhat.com> | 2007-12-31 03:11:19 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:00:18 -0500 |
commit | 3ab224be6d69de912ee21302745ea45a99274dbc (patch) | |
tree | 335dcef1cfacfefe3f36c21d5f144e011bc3bfba /net/sctp | |
parent | a06b494b61de44617dd58612164bdde56fca7bfb (diff) |
[NET] CORE: Introducing new memory accounting interface.
This patch introduces new memory accounting functions for each network
protocol. Most of them are renamed from memory accounting functions
for stream protocols. At the same time, some stream memory accounting
functions are removed since other functions do same thing.
Renaming:
sk_stream_free_skb() -> sk_wmem_free_skb()
__sk_stream_mem_reclaim() -> __sk_mem_reclaim()
sk_stream_mem_reclaim() -> sk_mem_reclaim()
sk_stream_mem_schedule -> __sk_mem_schedule()
sk_stream_pages() -> sk_mem_pages()
sk_stream_rmem_schedule() -> sk_rmem_schedule()
sk_stream_wmem_schedule() -> sk_wmem_schedule()
sk_charge_skb() -> sk_mem_charge()
Removeing
sk_stream_rfree(): consolidates into sock_rfree()
sk_stream_set_owner_r(): consolidates into skb_set_owner_r()
sk_stream_mem_schedule()
The following functions are added.
sk_has_account(): check if the protocol supports accounting
sk_mem_uncharge(): do the opposite of sk_mem_charge()
In addition, to achieve consolidation, updating sk_wmem_queued is
removed from sk_mem_charge().
Next, to consolidate memory accounting functions, this patch adds
memory accounting calls to network core functions. Moreover, present
memory accounting call is renamed to new accounting call.
Finally we replace present memory accounting calls with new interface
in TCP and SCTP.
Signed-off-by: Takahiro Yasui <tyasui@redhat.com>
Signed-off-by: Hideo Aoki <haoki@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/protocol.c | 2 | ||||
-rw-r--r-- | net/sctp/sm_statefuns.c | 2 | ||||
-rw-r--r-- | net/sctp/socket.c | 11 | ||||
-rw-r--r-- | net/sctp/ulpevent.c | 2 | ||||
-rw-r--r-- | net/sctp/ulpqueue.c | 2 |
5 files changed, 10 insertions, 9 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index e466e00b9a9f..b92196495027 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -1109,7 +1109,7 @@ SCTP_STATIC __init int sctp_init(void) | |||
1109 | sysctl_sctp_rmem[1] = (1500 *(sizeof(struct sk_buff) + 1)); | 1109 | sysctl_sctp_rmem[1] = (1500 *(sizeof(struct sk_buff) + 1)); |
1110 | sysctl_sctp_rmem[2] = max(sysctl_sctp_rmem[1], max_share); | 1110 | sysctl_sctp_rmem[2] = max(sysctl_sctp_rmem[1], max_share); |
1111 | 1111 | ||
1112 | sysctl_sctp_wmem[0] = SK_STREAM_MEM_QUANTUM; | 1112 | sysctl_sctp_wmem[0] = SK_MEM_QUANTUM; |
1113 | sysctl_sctp_wmem[1] = 16*1024; | 1113 | sysctl_sctp_wmem[1] = 16*1024; |
1114 | sysctl_sctp_wmem[2] = max(64*1024, max_share); | 1114 | sysctl_sctp_wmem[2] = max(64*1024, max_share); |
1115 | 1115 | ||
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 511d8c9a171a..b1267519183b 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c | |||
@@ -5844,7 +5844,7 @@ static int sctp_eat_data(const struct sctp_association *asoc, | |||
5844 | /* | 5844 | /* |
5845 | * Also try to renege to limit our memory usage in the event that | 5845 | * Also try to renege to limit our memory usage in the event that |
5846 | * we are under memory pressure | 5846 | * we are under memory pressure |
5847 | * If we can't renege, don't worry about it, the sk_stream_rmem_schedule | 5847 | * If we can't renege, don't worry about it, the sk_rmem_schedule |
5848 | * in sctp_ulpevent_make_rcvmsg will drop the frame if we grow our | 5848 | * in sctp_ulpevent_make_rcvmsg will drop the frame if we grow our |
5849 | * memory usage too much | 5849 | * memory usage too much |
5850 | */ | 5850 | */ |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 7a8650f01d08..710df67a6785 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -174,7 +174,8 @@ static inline void sctp_set_owner_w(struct sctp_chunk *chunk) | |||
174 | sizeof(struct sctp_chunk); | 174 | sizeof(struct sctp_chunk); |
175 | 175 | ||
176 | atomic_add(sizeof(struct sctp_chunk), &sk->sk_wmem_alloc); | 176 | atomic_add(sizeof(struct sctp_chunk), &sk->sk_wmem_alloc); |
177 | sk_charge_skb(sk, chunk->skb); | 177 | sk->sk_wmem_queued += chunk->skb->truesize; |
178 | sk_mem_charge(sk, chunk->skb->truesize); | ||
178 | } | 179 | } |
179 | 180 | ||
180 | /* Verify that this is a valid address. */ | 181 | /* Verify that this is a valid address. */ |
@@ -6035,10 +6036,10 @@ static void sctp_wfree(struct sk_buff *skb) | |||
6035 | atomic_sub(sizeof(struct sctp_chunk), &sk->sk_wmem_alloc); | 6036 | atomic_sub(sizeof(struct sctp_chunk), &sk->sk_wmem_alloc); |
6036 | 6037 | ||
6037 | /* | 6038 | /* |
6038 | * This undoes what is done via sk_charge_skb | 6039 | * This undoes what is done via sctp_set_owner_w and sk_mem_charge |
6039 | */ | 6040 | */ |
6040 | sk->sk_wmem_queued -= skb->truesize; | 6041 | sk->sk_wmem_queued -= skb->truesize; |
6041 | sk->sk_forward_alloc += skb->truesize; | 6042 | sk_mem_uncharge(sk, skb->truesize); |
6042 | 6043 | ||
6043 | sock_wfree(skb); | 6044 | sock_wfree(skb); |
6044 | __sctp_write_space(asoc); | 6045 | __sctp_write_space(asoc); |
@@ -6059,9 +6060,9 @@ void sctp_sock_rfree(struct sk_buff *skb) | |||
6059 | atomic_sub(event->rmem_len, &sk->sk_rmem_alloc); | 6060 | atomic_sub(event->rmem_len, &sk->sk_rmem_alloc); |
6060 | 6061 | ||
6061 | /* | 6062 | /* |
6062 | * Mimic the behavior of sk_stream_rfree | 6063 | * Mimic the behavior of sock_rfree |
6063 | */ | 6064 | */ |
6064 | sk->sk_forward_alloc += event->rmem_len; | 6065 | sk_mem_uncharge(sk, event->rmem_len); |
6065 | } | 6066 | } |
6066 | 6067 | ||
6067 | 6068 | ||
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c index 307314356e16..047c27df98f4 100644 --- a/net/sctp/ulpevent.c +++ b/net/sctp/ulpevent.c | |||
@@ -700,7 +700,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc, | |||
700 | if (rx_count >= asoc->base.sk->sk_rcvbuf) { | 700 | if (rx_count >= asoc->base.sk->sk_rcvbuf) { |
701 | 701 | ||
702 | if ((asoc->base.sk->sk_userlocks & SOCK_RCVBUF_LOCK) || | 702 | if ((asoc->base.sk->sk_userlocks & SOCK_RCVBUF_LOCK) || |
703 | (!sk_stream_rmem_schedule(asoc->base.sk, chunk->skb))) | 703 | (!sk_rmem_schedule(asoc->base.sk, chunk->skb->truesize))) |
704 | goto fail; | 704 | goto fail; |
705 | } | 705 | } |
706 | 706 | ||
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c index 1733fa29a501..c25caefa3bcb 100644 --- a/net/sctp/ulpqueue.c +++ b/net/sctp/ulpqueue.c | |||
@@ -1046,7 +1046,7 @@ void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, | |||
1046 | sctp_ulpq_partial_delivery(ulpq, chunk, gfp); | 1046 | sctp_ulpq_partial_delivery(ulpq, chunk, gfp); |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | sk_stream_mem_reclaim(asoc->base.sk); | 1049 | sk_mem_reclaim(asoc->base.sk); |
1050 | return; | 1050 | return; |
1051 | } | 1051 | } |
1052 | 1052 | ||