* [PATCH 1/4] [CORE]: introducing new memory accounting interface
2007-12-30 8:47 [PATCH 0/4] New interface for memory accounting (take 1) Hideo AOKI
@ 2007-12-30 8:51 ` Hideo AOKI
2007-12-30 8:51 ` [PATCH 2/4] [CORE]: adding memory accounting points Hideo AOKI
` (3 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Hideo AOKI @ 2007-12-30 8:51 UTC (permalink / raw)
To: David Miller, Herbert Xu, vladislav.yasevich, netdev
Cc: lksctp-developers, Takahiro Yasui, Masami Hiramatsu,
Satoshi Oshima, billfink, Andi Kleen, Evgeniy Polyakov,
Stephen Hemminger, yoshfuji, Yumiko Sugita, haoki
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().
Cc: Satoshi Oshima <satoshi.oshima.fk@hitachi.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
signed-off-by: Takahiro Yasui <tyasui@redhat.com>
signed-off-by: Hideo Aoki <haoki@redhat.com>
---
include/net/sock.h | 95 ++++++++++++++++++++++++++++++---------------------
net/core/sock.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++
net/core/stream.c | 82 --------------------------------------------
3 files changed, 152 insertions(+), 122 deletions(-)
diff -pruN net-2.6.25/include/net/sock.h net-2.6.25-t12t19m-p1/include/net/sock.h
--- net-2.6.25/include/net/sock.h 2007-12-27 10:18:58.000000000 -0500
+++ net-2.6.25-t12t19m-p1/include/net/sock.h 2007-12-29 20:16:31.000000000 -0500
@@ -460,25 +460,6 @@ static inline int sk_stream_memory_free(
return sk->sk_wmem_queued < sk->sk_sndbuf;
}
-extern void sk_stream_rfree(struct sk_buff *skb);
-
-static inline void sk_stream_set_owner_r(struct sk_buff *skb, struct sock *sk)
-{
- skb->sk = sk;
- skb->destructor = sk_stream_rfree;
- atomic_add(skb->truesize, &sk->sk_rmem_alloc);
- sk->sk_forward_alloc -= skb->truesize;
-}
-
-static inline void sk_stream_free_skb(struct sock *sk, struct sk_buff *skb)
-{
- skb_truesize_check(skb);
- sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
- sk->sk_wmem_queued -= skb->truesize;
- sk->sk_forward_alloc += skb->truesize;
- __kfree_skb(skb);
-}
-
/* The per-socket spinlock must be held here. */
static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb)
{
@@ -576,7 +557,7 @@ struct proto {
/*
* Pressure flag: try to collapse.
* Technical note: it is used by multiple contexts non atomically.
- * All the sk_stream_mem_schedule() is of this nature: accounting
+ * All the __sk_mem_schedule() is of this nature: accounting
* is strict, actions are advisory and have some latency.
*/
int *memory_pressure;
@@ -712,33 +693,73 @@ static inline struct inode *SOCK_INODE(s
return &container_of(socket, struct socket_alloc, socket)->vfs_inode;
}
-extern void __sk_stream_mem_reclaim(struct sock *sk);
-extern int sk_stream_mem_schedule(struct sock *sk, int size, int kind);
+/*
+ * Functions for memory accounting
+ */
+extern int __sk_mem_schedule(struct sock *sk, int size, int kind);
+extern void __sk_mem_reclaim(struct sock *sk);
-#define SK_STREAM_MEM_QUANTUM ((int)PAGE_SIZE)
-#define SK_STREAM_MEM_QUANTUM_SHIFT ilog2(SK_STREAM_MEM_QUANTUM)
+#define SK_MEM_QUANTUM ((int)PAGE_SIZE)
+#define SK_MEM_QUANTUM_SHIFT ilog2(SK_MEM_QUANTUM)
+#define SK_MEM_SEND 0
+#define SK_MEM_RECV 1
-static inline int sk_stream_pages(int amt)
+static inline int sk_mem_pages(int amt)
{
- return (amt + SK_STREAM_MEM_QUANTUM - 1) >> SK_STREAM_MEM_QUANTUM_SHIFT;
+ return (amt + SK_MEM_QUANTUM - 1) >> SK_MEM_QUANTUM_SHIFT;
}
-static inline void sk_stream_mem_reclaim(struct sock *sk)
+static inline int sk_has_account(struct sock *sk)
{
- if (sk->sk_forward_alloc >= SK_STREAM_MEM_QUANTUM)
- __sk_stream_mem_reclaim(sk);
+ /* return true if protocol supports memory accounting */
+ return !!sk->sk_prot->memory_allocated;
}
-static inline int sk_stream_rmem_schedule(struct sock *sk, struct sk_buff *skb)
+static inline int sk_wmem_schedule(struct sock *sk, int size)
{
- return (int)skb->truesize <= sk->sk_forward_alloc ||
- sk_stream_mem_schedule(sk, skb->truesize, 1);
+ if (!sk_has_account(sk))
+ return 1;
+ return size <= sk->sk_forward_alloc ||
+ __sk_mem_schedule(sk, size, SK_MEM_SEND);
}
-static inline int sk_stream_wmem_schedule(struct sock *sk, int size)
+static inline int sk_rmem_schedule(struct sock *sk, int size)
{
+ if (!sk_has_account(sk))
+ return 1;
return size <= sk->sk_forward_alloc ||
- sk_stream_mem_schedule(sk, size, 0);
+ __sk_mem_schedule(sk, size, SK_MEM_RECV);
+}
+
+static inline void sk_mem_reclaim(struct sock *sk)
+{
+ if (!sk_has_account(sk))
+ return;
+ if (sk->sk_forward_alloc >= SK_MEM_QUANTUM)
+ __sk_mem_reclaim(sk);
+}
+
+static inline void sk_mem_charge(struct sock *sk, int size)
+{
+ if (!sk_has_account(sk))
+ return;
+ sk->sk_forward_alloc -= size;
+}
+
+static inline void sk_mem_uncharge(struct sock *sk, int size)
+{
+ if (!sk_has_account(sk))
+ return;
+ sk->sk_forward_alloc += size;
+}
+
+static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
+{
+ skb_truesize_check(skb);
+ sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
+ sk->sk_wmem_queued -= skb->truesize;
+ sk_mem_uncharge(sk, skb->truesize);
+ __kfree_skb(skb);
}
/* Used by processes to "lock" a socket state, so that
@@ -1076,12 +1097,6 @@ static inline int sk_can_gso(const struc
extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst);
-static inline void sk_charge_skb(struct sock *sk, struct sk_buff *skb)
-{
- sk->sk_wmem_queued += skb->truesize;
- sk->sk_forward_alloc -= skb->truesize;
-}
-
static inline int skb_copy_to_page(struct sock *sk, char __user *from,
struct sk_buff *skb, struct page *page,
int off, int copy)
diff -pruN net-2.6.25/net/core/sock.c net-2.6.25-t12t19m-p1/net/core/sock.c
--- net-2.6.25/net/core/sock.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p1/net/core/sock.c 2007-12-29 20:16:31.000000000 -0500
@@ -1384,6 +1384,103 @@ int sk_wait_data(struct sock *sk, long *
EXPORT_SYMBOL(sk_wait_data);
+/**
+ * __sk_mem_schedule - increase sk_forward_alloc and memory_allocated
+ * @sk: socket
+ * @size: memory size to allocate
+ * @kind: allocation type
+ *
+ * If kind is SK_MEM_SEND, it means wmem allocation. Otherwise it means
+ * rmem allocation. This function assumes that protocols which have
+ * memory_pressure use sk_wmem_queued as write buffer accounting.
+ */
+int __sk_mem_schedule(struct sock *sk, int size, int kind)
+{
+ struct proto *prot = sk->sk_prot;
+ int amt = sk_mem_pages(size);
+ int allocated;
+
+ sk->sk_forward_alloc += amt * SK_MEM_QUANTUM;
+ allocated = atomic_add_return(amt, prot->memory_allocated);
+
+ /* Under limit. */
+ if (allocated <= prot->sysctl_mem[0]) {
+ if (prot->memory_pressure && *prot->memory_pressure)
+ *prot->memory_pressure = 0;
+ return 1;
+ }
+
+ /* Under pressure. */
+ if (allocated > prot->sysctl_mem[1])
+ if (prot->enter_memory_pressure)
+ prot->enter_memory_pressure();
+
+ /* Over hard limit. */
+ if (allocated > prot->sysctl_mem[2])
+ goto suppress_allocation;
+
+ /* guarantee minimum buffer size under pressure */
+ if (kind == SK_MEM_RECV) {
+ if (atomic_read(&sk->sk_rmem_alloc) < prot->sysctl_rmem[0])
+ return 1;
+ } else { /* SK_MEM_SEND */
+ if (sk->sk_type == SOCK_STREAM) {
+ if (sk->sk_wmem_queued < prot->sysctl_wmem[0])
+ return 1;
+ } else if (atomic_read(&sk->sk_wmem_alloc) <
+ prot->sysctl_wmem[0])
+ return 1;
+ }
+
+ if (prot->memory_pressure) {
+ if (!*prot->memory_pressure ||
+ prot->sysctl_mem[2] > atomic_read(prot->sockets_allocated) *
+ sk_mem_pages(sk->sk_wmem_queued +
+ atomic_read(&sk->sk_rmem_alloc) +
+ sk->sk_forward_alloc))
+ return 1;
+ }
+
+suppress_allocation:
+
+ if (kind == SK_MEM_SEND && sk->sk_type == SOCK_STREAM) {
+ sk_stream_moderate_sndbuf(sk);
+
+ /* Fail only if socket is _under_ its sndbuf.
+ * In this case we cannot block, so that we have to fail.
+ */
+ if (sk->sk_wmem_queued + size >= sk->sk_sndbuf)
+ return 1;
+ }
+
+ /* Alas. Undo changes. */
+ sk->sk_forward_alloc -= amt * SK_MEM_QUANTUM;
+ atomic_sub(amt, prot->memory_allocated);
+ return 0;
+}
+
+EXPORT_SYMBOL(__sk_mem_schedule);
+
+/**
+ * __sk_reclaim - reclaim memory_allocated
+ * @sk: socket
+ */
+void __sk_mem_reclaim(struct sock *sk)
+{
+ struct proto *prot = sk->sk_prot;
+
+ atomic_sub(sk->sk_forward_alloc / SK_MEM_QUANTUM,
+ prot->memory_allocated);
+ sk->sk_forward_alloc &= SK_MEM_QUANTUM - 1;
+
+ if (prot->memory_pressure && *prot->memory_pressure &&
+ (atomic_read(prot->memory_allocated) < prot->sysctl_mem[0]))
+ *prot->memory_pressure = 0;
+}
+
+EXPORT_SYMBOL(__sk_mem_reclaim);
+
+
/*
* Set of default routines for initialising struct proto_ops when
* the protocol does not support a particular function. In certain
diff -pruN net-2.6.25/net/core/stream.c net-2.6.25-t12t19m-p1/net/core/stream.c
--- net-2.6.25/net/core/stream.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p1/net/core/stream.c 2007-12-29 20:16:31.000000000 -0500
@@ -172,17 +172,6 @@ do_interrupted:
EXPORT_SYMBOL(sk_stream_wait_memory);
-void sk_stream_rfree(struct sk_buff *skb)
-{
- struct sock *sk = skb->sk;
-
- skb_truesize_check(skb);
- atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
- sk->sk_forward_alloc += skb->truesize;
-}
-
-EXPORT_SYMBOL(sk_stream_rfree);
-
int sk_stream_error(struct sock *sk, int flags, int err)
{
if (err == -EPIPE)
@@ -194,77 +183,6 @@ int sk_stream_error(struct sock *sk, int
EXPORT_SYMBOL(sk_stream_error);
-void __sk_stream_mem_reclaim(struct sock *sk)
-{
- atomic_sub(sk->sk_forward_alloc >> SK_STREAM_MEM_QUANTUM_SHIFT,
- sk->sk_prot->memory_allocated);
- sk->sk_forward_alloc &= SK_STREAM_MEM_QUANTUM - 1;
- if (*sk->sk_prot->memory_pressure &&
- (atomic_read(sk->sk_prot->memory_allocated) <
- sk->sk_prot->sysctl_mem[0]))
- *sk->sk_prot->memory_pressure = 0;
-}
-
-EXPORT_SYMBOL(__sk_stream_mem_reclaim);
-
-int sk_stream_mem_schedule(struct sock *sk, int size, int kind)
-{
- int amt = sk_stream_pages(size);
- struct proto *prot = sk->sk_prot;
-
- sk->sk_forward_alloc += amt * SK_STREAM_MEM_QUANTUM;
- atomic_add(amt, prot->memory_allocated);
-
- /* Under limit. */
- if (atomic_read(prot->memory_allocated) < prot->sysctl_mem[0]) {
- if (*prot->memory_pressure)
- *prot->memory_pressure = 0;
- return 1;
- }
-
- /* Over hard limit. */
- if (atomic_read(prot->memory_allocated) > prot->sysctl_mem[2]) {
- prot->enter_memory_pressure();
- goto suppress_allocation;
- }
-
- /* Under pressure. */
- if (atomic_read(prot->memory_allocated) > prot->sysctl_mem[1])
- prot->enter_memory_pressure();
-
- if (kind) {
- if (atomic_read(&sk->sk_rmem_alloc) < prot->sysctl_rmem[0])
- return 1;
- } else if (sk->sk_wmem_queued < prot->sysctl_wmem[0])
- return 1;
-
- if (!*prot->memory_pressure ||
- prot->sysctl_mem[2] > atomic_read(prot->sockets_allocated) *
- sk_stream_pages(sk->sk_wmem_queued +
- atomic_read(&sk->sk_rmem_alloc) +
- sk->sk_forward_alloc))
- return 1;
-
-suppress_allocation:
-
- if (!kind) {
- sk_stream_moderate_sndbuf(sk);
-
- /* Fail only if socket is _under_ its sndbuf.
- * In this case we cannot block, so that we have to fail.
- */
- if (sk->sk_wmem_queued + size >= sk->sk_sndbuf)
- return 1;
- }
-
- /* Alas. Undo changes. */
- sk->sk_forward_alloc -= amt * SK_STREAM_MEM_QUANTUM;
- atomic_sub(amt, prot->memory_allocated);
- return 0;
-}
-
-EXPORT_SYMBOL(sk_stream_mem_schedule);
-
void sk_stream_kill_queues(struct sock *sk)
{
/* First the read buffer. */
--
Hitachi Computer Products (America) Inc.
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH 2/4] [CORE]: adding memory accounting points
2007-12-30 8:47 [PATCH 0/4] New interface for memory accounting (take 1) Hideo AOKI
2007-12-30 8:51 ` [PATCH 1/4] [CORE]: introducing new memory accounting interface Hideo AOKI
@ 2007-12-30 8:51 ` Hideo AOKI
2007-12-31 7:58 ` David Miller
2007-12-30 8:53 ` [PATCH 3/4] [TCP]: using new interface Hideo AOKI
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Hideo AOKI @ 2007-12-30 8:51 UTC (permalink / raw)
To: David Miller, Herbert Xu, vladislav.yasevich, netdev
Cc: lksctp-developers, Takahiro Yasui, Masami Hiramatsu,
Satoshi Oshima, billfink, Andi Kleen, Evgeniy Polyakov,
Stephen Hemminger, yoshfuji, Yumiko Sugita, haoki
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.
Cc: Satoshi Oshima <satoshi.oshima.fk@hitachi.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
signed-off-by: Takahiro Yasui <tyasui@redhat.com>
signed-off-by: Hideo Aoki <haoki@redhat.com>
---
include/net/sock.h | 3 ++-
net/core/datagram.c | 2 ++
net/core/sock.c | 7 +++++++
net/core/stream.c | 2 +-
4 files changed, 12 insertions(+), 2 deletions(-)
diff -pruN net-2.6.25-t12t19m-p1/include/net/sock.h net-2.6.25-t12t19m-p2/include/net/sock.h
--- net-2.6.25-t12t19m-p1/include/net/sock.h 2007-12-29 20:16:31.000000000 -0500
+++ net-2.6.25-t12t19m-p2/include/net/sock.h 2007-12-29 20:28:15.000000000 -0500
@@ -1116,7 +1116,7 @@ static inline int skb_copy_to_page(struc
skb->data_len += copy;
skb->truesize += copy;
sk->sk_wmem_queued += copy;
- sk->sk_forward_alloc -= copy;
+ sk_mem_charge(sk, copy);
return 0;
}
@@ -1142,6 +1142,7 @@ static inline void skb_set_owner_r(struc
skb->sk = sk;
skb->destructor = sock_rfree;
atomic_add(skb->truesize, &sk->sk_rmem_alloc);
+ sk_mem_charge(sk, skb->truesize);
}
extern void sk_reset_timer(struct sock *sk, struct timer_list* timer,
diff -pruN net-2.6.25-t12t19m-p1/net/core/datagram.c net-2.6.25-t12t19m-p2/net/core/datagram.c
--- net-2.6.25-t12t19m-p1/net/core/datagram.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p2/net/core/datagram.c 2007-12-29 20:28:15.000000000 -0500
@@ -209,6 +209,7 @@ struct sk_buff *skb_recv_datagram(struct
void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
{
kfree_skb(skb);
+ sk_mem_reclaim(sk);
}
/**
@@ -248,6 +249,7 @@ int skb_kill_datagram(struct sock *sk, s
}
kfree_skb(skb);
+ sk_mem_reclaim(sk);
return err;
}
diff -pruN net-2.6.25-t12t19m-p1/net/core/sock.c net-2.6.25-t12t19m-p2/net/core/sock.c
--- net-2.6.25-t12t19m-p1/net/core/sock.c 2007-12-29 20:16:31.000000000 -0500
+++ net-2.6.25-t12t19m-p2/net/core/sock.c 2007-12-29 20:28:15.000000000 -0500
@@ -282,6 +282,11 @@ int sock_queue_rcv_skb(struct sock *sk,
if (err)
goto out;
+ if (!sk_rmem_schedule(sk, skb->truesize)) {
+ err = -ENOBUFS;
+ goto out;
+ }
+
skb->dev = NULL;
skb_set_owner_r(skb, sk);
@@ -1107,7 +1112,9 @@ void sock_rfree(struct sk_buff *skb)
{
struct sock *sk = skb->sk;
+ skb_truesize_check(skb);
atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
+ sk_mem_uncharge(skb->sk, skb->truesize);
}
diff -pruN net-2.6.25-t12t19m-p1/net/core/stream.c net-2.6.25-t12t19m-p2/net/core/stream.c
--- net-2.6.25-t12t19m-p1/net/core/stream.c 2007-12-29 20:16:31.000000000 -0500
+++ net-2.6.25-t12t19m-p2/net/core/stream.c 2007-12-29 20:28:15.000000000 -0500
@@ -195,7 +195,7 @@ void sk_stream_kill_queues(struct sock *
BUG_TRAP(skb_queue_empty(&sk->sk_write_queue));
/* Account for returned memory. */
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
BUG_TRAP(!sk->sk_wmem_queued);
BUG_TRAP(!sk->sk_forward_alloc);
--
Hitachi Computer Products (America) Inc.
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 2/4] [CORE]: adding memory accounting points
2007-12-30 8:51 ` [PATCH 2/4] [CORE]: adding memory accounting points Hideo AOKI
@ 2007-12-31 7:58 ` David Miller
2007-12-31 18:52 ` Hideo AOKI
0 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2007-12-31 7:58 UTC (permalink / raw)
To: haoki
Cc: herbert, vladislav.yasevich, netdev, lksctp-developers, tyasui,
mhiramat, satoshi.oshima.fk, billfink, andi, johnpol, shemminger,
yoshfuji, yumiko.sugita.yf
From: Hideo AOKI <haoki@redhat.com>
Date: Sun, 30 Dec 2007 03:51:44 -0500
> 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.
>
> Cc: Satoshi Oshima <satoshi.oshima.fk@hitachi.com>
> Cc: Masami Hiramatsu <mhiramat@redhat.com>
> signed-off-by: Takahiro Yasui <tyasui@redhat.com>
> signed-off-by: Hideo Aoki <haoki@redhat.com>
This patch would not apply, because is contained changes
present in the first patch, specifically:
> diff -pruN net-2.6.25-t12t19m-p1/include/net/sock.h net-2.6.25-t12t19m-p2/include/net/sock.h
> --- net-2.6.25-t12t19m-p1/include/net/sock.h 2007-12-29 20:16:31.000000000 -0500
> +++ net-2.6.25-t12t19m-p2/include/net/sock.h 2007-12-29 20:28:15.000000000 -0500
> @@ -1116,7 +1116,7 @@ static inline int skb_copy_to_page(struc
> skb->data_len += copy;
> skb->truesize += copy;
> sk->sk_wmem_queued += copy;
> - sk->sk_forward_alloc -= copy;
> + sk_mem_charge(sk, copy);
> return 0;
> }
>
> @@ -1142,6 +1142,7 @@ static inline void skb_set_owner_r(struc
> skb->sk = sk;
> skb->destructor = sock_rfree;
> atomic_add(skb->truesize, &sk->sk_rmem_alloc);
> + sk_mem_charge(sk, skb->truesize);
> }
>
> extern void sk_reset_timer(struct sock *sk, struct timer_list* timer,
And now I see exactly what you did, and it is quite careless.
You wrote one big patch then tried to split it up by hand. This
proves to me that you did not test the patches individually. Even
worse, you did not even try to apply each patch nor compile the tree
each step along the way as a basic sanity check.
This wastes a lot of my time, as well as the time of other developers
who might want to try out and test your changes.
I will fix it up this time, but please do not ever do this again.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/4] [CORE]: adding memory accounting points
2007-12-31 7:58 ` David Miller
@ 2007-12-31 18:52 ` Hideo AOKI
0 siblings, 0 replies; 12+ messages in thread
From: Hideo AOKI @ 2007-12-31 18:52 UTC (permalink / raw)
To: David Miller
Cc: herbert, vladislav.yasevich, netdev, lksctp-developers, tyasui,
mhiramat, satoshi.oshima.fk, billfink, andi, johnpol, shemminger,
yoshfuji, yumiko.sugita.yf, haoki
David Miller wrote:
> This patch would not apply, because is contained changes
> present in the first patch, specifically:
<snip>
> And now I see exactly what you did, and it is quite careless.
>
> You wrote one big patch then tried to split it up by hand. This
> proves to me that you did not test the patches individually. Even
> worse, you did not even try to apply each patch nor compile the tree
> each step along the way as a basic sanity check.
Hello David,
You are right. Since I felt the patch was big, I divided
into three for review. And I mistook during the dividing.
> This wastes a lot of my time, as well as the time of other developers
> who might want to try out and test your changes.
I apologize for wasting your time.
> I will fix it up this time, but please do not ever do this again.
I really appreciate the fix. And I understood this.
Best regards,
Hideo
--
Hitachi Computer Products (America) Inc.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/4] [TCP]: using new interface
2007-12-30 8:47 [PATCH 0/4] New interface for memory accounting (take 1) Hideo AOKI
2007-12-30 8:51 ` [PATCH 1/4] [CORE]: introducing new memory accounting interface Hideo AOKI
2007-12-30 8:51 ` [PATCH 2/4] [CORE]: adding memory accounting points Hideo AOKI
@ 2007-12-30 8:53 ` Hideo AOKI
2007-12-30 8:54 ` [PATCH 4/4] [SCTP]: " Hideo AOKI
2007-12-31 7:34 ` [PATCH 0/4] New interface for memory accounting (take 1) David Miller
4 siblings, 0 replies; 12+ messages in thread
From: Hideo AOKI @ 2007-12-30 8:53 UTC (permalink / raw)
To: David Miller, Herbert Xu, vladislav.yasevich, netdev
Cc: lksctp-developers, Takahiro Yasui, Masami Hiramatsu,
Satoshi Oshima, billfink, Andi Kleen, Evgeniy Polyakov,
Stephen Hemminger, yoshfuji, Yumiko Sugita, haoki
This patch replaces present memory accounting calls with new interface
in TCP.
Cc: Satoshi Oshima <satoshi.oshima.fk@hitachi.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
signed-off-by: Takahiro Yasui <tyasui@redhat.com>
signed-off-by: Hideo Aoki <haoki@redhat.com>
---
include/net/tcp.h | 4 ++--
net/ipv4/tcp.c | 23 ++++++++++++-----------
net/ipv4/tcp_input.c | 26 +++++++++++++-------------
net/ipv4/tcp_output.c | 26 ++++++++++++++++----------
net/ipv4/tcp_timer.c | 8 ++++----
5 files changed, 47 insertions(+), 40 deletions(-)
diff -pruN net-2.6.25-t12t19m-p2/include/net/tcp.h net-2.6.25-t12t19m-p3/include/net/tcp.h
--- net-2.6.25-t12t19m-p2/include/net/tcp.h 2007-12-27 10:18:58.000000000 -0500
+++ net-2.6.25-t12t19m-p3/include/net/tcp.h 2007-12-29 20:49:59.000000000 -0500
@@ -1196,8 +1196,8 @@ static inline void tcp_write_queue_purge
struct sk_buff *skb;
while ((skb = __skb_dequeue(&sk->sk_write_queue)) != NULL)
- sk_stream_free_skb(sk, skb);
- sk_stream_mem_reclaim(sk);
+ sk_wmem_free_skb(sk, skb);
+ sk_mem_reclaim(sk);
}
static inline struct sk_buff *tcp_write_queue_head(struct sock *sk)
diff -pruN net-2.6.25-t12t19m-p2/net/ipv4/tcp.c net-2.6.25-t12t19m-p3/net/ipv4/tcp.c
--- net-2.6.25-t12t19m-p2/net/ipv4/tcp.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p3/net/ipv4/tcp.c 2007-12-29 20:49:59.000000000 -0500
@@ -308,7 +308,7 @@ struct tcp_splice_state {
/*
* Pressure flag: try to collapse.
* Technical note: it is used by multiple contexts non atomically.
- * All the sk_stream_mem_schedule() is of this nature: accounting
+ * All the __sk_mem_schedule() is of this nature: accounting
* is strict, actions are advisory and have some latency.
*/
int tcp_memory_pressure __read_mostly;
@@ -485,7 +485,8 @@ static inline void skb_entail(struct soc
tcb->sacked = 0;
skb_header_release(skb);
tcp_add_write_queue_tail(sk, skb);
- sk_charge_skb(sk, skb);
+ sk->sk_wmem_queued += skb->truesize;
+ sk_mem_charge(sk, skb->truesize);
if (tp->nonagle & TCP_NAGLE_PUSH)
tp->nonagle &= ~TCP_NAGLE_PUSH;
}
@@ -638,7 +639,7 @@ struct sk_buff *sk_stream_alloc_skb(stru
skb = alloc_skb_fclone(size + sk->sk_prot->max_header, gfp);
if (skb) {
- if (sk_stream_wmem_schedule(sk, skb->truesize)) {
+ if (sk_wmem_schedule(sk, skb->truesize)) {
/*
* Make sure that we have exactly size bytes
* available to the caller, no more, no less.
@@ -707,7 +708,7 @@ new_segment:
tcp_mark_push(tp, skb);
goto new_segment;
}
- if (!sk_stream_wmem_schedule(sk, copy))
+ if (!sk_wmem_schedule(sk, copy))
goto wait_for_memory;
if (can_coalesce) {
@@ -721,7 +722,7 @@ new_segment:
skb->data_len += copy;
skb->truesize += copy;
sk->sk_wmem_queued += copy;
- sk->sk_forward_alloc -= copy;
+ sk_mem_charge(sk, copy);
skb->ip_summed = CHECKSUM_PARTIAL;
tp->write_seq += copy;
TCP_SKB_CB(skb)->end_seq += copy;
@@ -928,7 +929,7 @@ new_segment:
if (copy > PAGE_SIZE - off)
copy = PAGE_SIZE - off;
- if (!sk_stream_wmem_schedule(sk, copy))
+ if (!sk_wmem_schedule(sk, copy))
goto wait_for_memory;
if (!page) {
@@ -1019,7 +1020,7 @@ do_fault:
* reset, where we can be unlinking the send_head.
*/
tcp_check_send_head(sk, skb);
- sk_stream_free_skb(sk, skb);
+ sk_wmem_free_skb(sk, skb);
}
do_error:
@@ -1738,7 +1739,7 @@ void tcp_close(struct sock *sk, long tim
__kfree_skb(skb);
}
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
/* As outlined in RFC 2525, section 2.17, we send a RST here because
* data was lost. To witness the awful effects of the old behavior of
@@ -1841,7 +1842,7 @@ adjudge_to_death:
}
}
if (sk->sk_state != TCP_CLOSE) {
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
if (tcp_too_many_orphans(sk,
atomic_read(sk->sk_prot->orphan_count))) {
if (net_ratelimit())
@@ -2658,11 +2659,11 @@ void __init tcp_init(void)
limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7);
max_share = min(4UL*1024*1024, limit);
- sysctl_tcp_wmem[0] = SK_STREAM_MEM_QUANTUM;
+ sysctl_tcp_wmem[0] = SK_MEM_QUANTUM;
sysctl_tcp_wmem[1] = 16*1024;
sysctl_tcp_wmem[2] = max(64*1024, max_share);
- sysctl_tcp_rmem[0] = SK_STREAM_MEM_QUANTUM;
+ sysctl_tcp_rmem[0] = SK_MEM_QUANTUM;
sysctl_tcp_rmem[1] = 87380;
sysctl_tcp_rmem[2] = max(87380, max_share);
diff -pruN net-2.6.25-t12t19m-p2/net/ipv4/tcp_input.c net-2.6.25-t12t19m-p3/net/ipv4/tcp_input.c
--- net-2.6.25-t12t19m-p2/net/ipv4/tcp_input.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p3/net/ipv4/tcp_input.c 2007-12-29 20:49:59.000000000 -0500
@@ -591,7 +591,7 @@ static void tcp_event_data_recv(struct s
* restart window, so that we send ACKs quickly.
*/
tcp_incr_quickack(sk);
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
}
}
icsk->icsk_ack.lrcvtime = now;
@@ -2848,7 +2848,7 @@ static int tcp_clean_rtx_queue(struct so
break;
tcp_unlink_write_queue(skb, sk);
- sk_stream_free_skb(sk, skb);
+ sk_wmem_free_skb(sk, skb);
tcp_clear_all_retrans_hints(tp);
}
@@ -3564,7 +3564,7 @@ static void tcp_fin(struct sk_buff *skb,
__skb_queue_purge(&tp->out_of_order_queue);
if (tcp_is_sack(tp))
tcp_sack_reset(&tp->rx_opt);
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
if (!sock_flag(sk, SOCK_DEAD)) {
sk->sk_state_change(sk);
@@ -3847,12 +3847,12 @@ static void tcp_data_queue(struct sock *
queue_and_out:
if (eaten < 0 &&
(atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf ||
- !sk_stream_rmem_schedule(sk, skb))) {
+ !sk_rmem_schedule(sk, skb->truesize))) {
if (tcp_prune_queue(sk) < 0 ||
- !sk_stream_rmem_schedule(sk, skb))
+ !sk_rmem_schedule(sk, skb->truesize))
goto drop;
}
- sk_stream_set_owner_r(skb, sk);
+ skb_set_owner_r(skb, sk);
__skb_queue_tail(&sk->sk_receive_queue, skb);
}
tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
@@ -3921,9 +3921,9 @@ drop:
TCP_ECN_check_ce(tp, skb);
if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf ||
- !sk_stream_rmem_schedule(sk, skb)) {
+ !sk_rmem_schedule(sk, skb->truesize)) {
if (tcp_prune_queue(sk) < 0 ||
- !sk_stream_rmem_schedule(sk, skb))
+ !sk_rmem_schedule(sk, skb->truesize))
goto drop;
}
@@ -3934,7 +3934,7 @@ drop:
SOCK_DEBUG(sk, "out of order segment: rcv_next %X seq %X - %X\n",
tp->rcv_nxt, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq);
- sk_stream_set_owner_r(skb, sk);
+ skb_set_owner_r(skb, sk);
if (!skb_peek(&tp->out_of_order_queue)) {
/* Initial out of order segment, build 1 SACK. */
@@ -4076,7 +4076,7 @@ tcp_collapse(struct sock *sk, struct sk_
memcpy(nskb->cb, skb->cb, sizeof(skb->cb));
TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(nskb)->end_seq = start;
__skb_insert(nskb, skb->prev, skb, list);
- sk_stream_set_owner_r(nskb, sk);
+ skb_set_owner_r(nskb, sk);
/* Copy data, releasing collapsed skbs. */
while (copy > 0) {
@@ -4174,7 +4174,7 @@ static int tcp_prune_queue(struct sock *
sk->sk_receive_queue.next,
(struct sk_buff*)&sk->sk_receive_queue,
tp->copied_seq, tp->rcv_nxt);
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf)
return 0;
@@ -4194,7 +4194,7 @@ static int tcp_prune_queue(struct sock *
*/
if (tcp_is_sack(tp))
tcp_sack_reset(&tp->rx_opt);
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
}
if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf)
@@ -4696,7 +4696,7 @@ int tcp_rcv_established(struct sock *sk,
/* Bulk data transfer: receiver */
__skb_pull(skb,tcp_header_len);
__skb_queue_tail(&sk->sk_receive_queue, skb);
- sk_stream_set_owner_r(skb, sk);
+ skb_set_owner_r(skb, sk);
tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
}
diff -pruN net-2.6.25-t12t19m-p2/net/ipv4/tcp_output.c net-2.6.25-t12t19m-p3/net/ipv4/tcp_output.c
--- net-2.6.25-t12t19m-p2/net/ipv4/tcp_output.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p3/net/ipv4/tcp_output.c 2007-12-29 20:49:59.000000000 -0500
@@ -637,7 +637,8 @@ static void tcp_queue_skb(struct sock *s
tp->write_seq = TCP_SKB_CB(skb)->end_seq;
skb_header_release(skb);
tcp_add_write_queue_tail(sk, skb);
- sk_charge_skb(sk, skb);
+ sk->sk_wmem_queued += skb->truesize;
+ sk_mem_charge(sk, skb->truesize);
}
static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now)
@@ -701,7 +702,8 @@ int tcp_fragment(struct sock *sk, struct
if (buff == NULL)
return -ENOMEM; /* We'll just try again later. */
- sk_charge_skb(sk, buff);
+ sk->sk_wmem_queued += buff->truesize;
+ sk_mem_charge(sk, buff->truesize);
nlen = skb->len - len - nsize;
buff->truesize += nlen;
skb->truesize -= nlen;
@@ -825,7 +827,7 @@ int tcp_trim_head(struct sock *sk, struc
skb->truesize -= len;
sk->sk_wmem_queued -= len;
- sk->sk_forward_alloc += len;
+ sk_mem_uncharge(sk, len);
sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
/* Any change of skb->len requires recalculation of tso
@@ -1197,7 +1199,8 @@ static int tso_fragment(struct sock *sk,
if (unlikely(buff == NULL))
return -ENOMEM;
- sk_charge_skb(sk, buff);
+ sk->sk_wmem_queued += buff->truesize;
+ sk_mem_charge(sk, buff->truesize);
buff->truesize += nlen;
skb->truesize -= nlen;
@@ -1350,7 +1353,8 @@ static int tcp_mtu_probe(struct sock *sk
/* We're allowed to probe. Build it now. */
if ((nskb = sk_stream_alloc_skb(sk, probe_size, GFP_ATOMIC)) == NULL)
return -1;
- sk_charge_skb(sk, nskb);
+ sk->sk_wmem_queued += nskb->truesize;
+ sk_mem_charge(sk, nskb->truesize);
skb = tcp_send_head(sk);
@@ -1377,7 +1381,7 @@ static int tcp_mtu_probe(struct sock *sk
* Throw it away. */
TCP_SKB_CB(nskb)->flags |= TCP_SKB_CB(skb)->flags;
tcp_unlink_write_queue(skb, sk);
- sk_stream_free_skb(sk, skb);
+ sk_wmem_free_skb(sk, skb);
} else {
TCP_SKB_CB(nskb)->flags |= TCP_SKB_CB(skb)->flags &
~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH);
@@ -1744,7 +1748,7 @@ static void tcp_retrans_try_collapse(str
/* changed transmit queue under us so clear hints */
tcp_clear_retrans_hints_partial(tp);
- sk_stream_free_skb(sk, next_skb);
+ sk_wmem_free_skb(sk, next_skb);
}
}
@@ -2139,8 +2143,9 @@ int tcp_send_synack(struct sock *sk)
tcp_unlink_write_queue(skb, sk);
skb_header_release(nskb);
__tcp_add_write_queue_head(sk, nskb);
- sk_stream_free_skb(sk, skb);
- sk_charge_skb(sk, nskb);
+ sk_wmem_free_skb(sk, skb);
+ sk->sk_wmem_queued += nskb->truesize;
+ sk_mem_charge(sk, nskb->truesize);
skb = nskb;
}
@@ -2343,7 +2348,8 @@ int tcp_connect(struct sock *sk)
tp->retrans_stamp = TCP_SKB_CB(buff)->when;
skb_header_release(buff);
__tcp_add_write_queue_tail(sk, buff);
- sk_charge_skb(sk, buff);
+ sk->sk_wmem_queued += buff->truesize;
+ sk_mem_charge(sk, buff->truesize);
tp->packets_out += tcp_skb_pcount(buff);
tcp_transmit_skb(sk, buff, 1, GFP_KERNEL);
diff -pruN net-2.6.25-t12t19m-p2/net/ipv4/tcp_timer.c net-2.6.25-t12t19m-p3/net/ipv4/tcp_timer.c
--- net-2.6.25-t12t19m-p2/net/ipv4/tcp_timer.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p3/net/ipv4/tcp_timer.c 2007-12-29 20:49:59.000000000 -0500
@@ -186,7 +186,7 @@ static void tcp_delack_timer(unsigned lo
goto out_unlock;
}
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
if (sk->sk_state == TCP_CLOSE || !(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
goto out;
@@ -226,7 +226,7 @@ static void tcp_delack_timer(unsigned lo
out:
if (tcp_memory_pressure)
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
out_unlock:
bh_unlock_sock(sk);
sock_put(sk);
@@ -420,7 +420,7 @@ static void tcp_write_timer(unsigned lon
TCP_CHECK_TIMER(sk);
out:
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
out_unlock:
bh_unlock_sock(sk);
sock_put(sk);
@@ -514,7 +514,7 @@ static void tcp_keepalive_timer (unsigne
}
TCP_CHECK_TIMER(sk);
- sk_stream_mem_reclaim(sk);
+ sk_mem_reclaim(sk);
resched:
inet_csk_reset_keepalive_timer (sk, elapsed);
--
Hitachi Computer Products (America) Inc.
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH 4/4] [SCTP]: using new interface
2007-12-30 8:47 [PATCH 0/4] New interface for memory accounting (take 1) Hideo AOKI
` (2 preceding siblings ...)
2007-12-30 8:53 ` [PATCH 3/4] [TCP]: using new interface Hideo AOKI
@ 2007-12-30 8:54 ` Hideo AOKI
2007-12-31 7:34 ` [PATCH 0/4] New interface for memory accounting (take 1) David Miller
4 siblings, 0 replies; 12+ messages in thread
From: Hideo AOKI @ 2007-12-30 8:54 UTC (permalink / raw)
To: David Miller, Herbert Xu, vladislav.yasevich, netdev,
lksctp-developers
Cc: Takahiro Yasui, Masami Hiramatsu, Satoshi Oshima, billfink,
Andi Kleen, Evgeniy Polyakov, Stephen Hemminger, yoshfuji,
Yumiko Sugita, haoki
This patch replaces present memory accounting calls with new interface
in SCTP.
Cc: Satoshi Oshima <satoshi.oshima.fk@hitachi.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
signed-off-by: Takahiro Yasui <tyasui@redhat.com>
signed-off-by: Hideo Aoki <haoki@redhat.com>
---
include/net/sctp/sctp.h | 3 +--
net/sctp/protocol.c | 2 +-
net/sctp/sm_statefuns.c | 2 +-
net/sctp/socket.c | 11 ++++++-----
net/sctp/ulpevent.c | 2 +-
net/sctp/ulpqueue.c | 2 +-
6 files changed, 11 insertions(+), 11 deletions(-)
diff -pruN net-2.6.25-t12t19m-p3/include/net/sctp/sctp.h net-2.6.25-t12t19m-p4/include/net/sctp/sctp.h
--- net-2.6.25-t12t19m-p3/include/net/sctp/sctp.h 2007-12-27 10:18:58.000000000 -0500
+++ net-2.6.25-t12t19m-p4/include/net/sctp/sctp.h 2007-12-29 20:59:06.000000000 -0500
@@ -463,8 +463,7 @@ static inline void sctp_skb_set_owner_r(
skb->destructor = sctp_sock_rfree;
atomic_add(event->rmem_len, &sk->sk_rmem_alloc);
/*
- * This mimics the behavior of
- * sk_stream_set_owner_r
+ * This mimics the behavior of skb_set_owner_r
*/
sk->sk_forward_alloc -= event->rmem_len;
}
diff -pruN net-2.6.25-t12t19m-p3/net/sctp/protocol.c net-2.6.25-t12t19m-p4/net/sctp/protocol.c
--- net-2.6.25-t12t19m-p3/net/sctp/protocol.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p4/net/sctp/protocol.c 2007-12-29 20:59:06.000000000 -0500
@@ -1109,7 +1109,7 @@ SCTP_STATIC __init int sctp_init(void)
sysctl_sctp_rmem[1] = (1500 *(sizeof(struct sk_buff) + 1));
sysctl_sctp_rmem[2] = max(sysctl_sctp_rmem[1], max_share);
- sysctl_sctp_wmem[0] = SK_STREAM_MEM_QUANTUM;
+ sysctl_sctp_wmem[0] = SK_MEM_QUANTUM;
sysctl_sctp_wmem[1] = 16*1024;
sysctl_sctp_wmem[2] = max(64*1024, max_share);
diff -pruN net-2.6.25-t12t19m-p3/net/sctp/sm_statefuns.c net-2.6.25-t12t19m-p4/net/sctp/sm_statefuns.c
--- net-2.6.25-t12t19m-p3/net/sctp/sm_statefuns.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p4/net/sctp/sm_statefuns.c 2007-12-29 20:59:06.000000000 -0500
@@ -5866,7 +5866,7 @@ static int sctp_eat_data(const struct sc
/*
* Also try to renege to limit our memory usage in the event that
* we are under memory pressure
- * If we can't renege, don't worry about it, the sk_stream_rmem_schedule
+ * If we can't renege, don't worry about it, the sk_rmem_schedule
* in sctp_ulpevent_make_rcvmsg will drop the frame if we grow our
* memory usage too much
*/
diff -pruN net-2.6.25-t12t19m-p3/net/sctp/socket.c net-2.6.25-t12t19m-p4/net/sctp/socket.c
--- net-2.6.25-t12t19m-p3/net/sctp/socket.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p4/net/sctp/socket.c 2007-12-29 20:59:06.000000000 -0500
@@ -174,7 +174,8 @@ static inline void sctp_set_owner_w(stru
sizeof(struct sctp_chunk);
atomic_add(sizeof(struct sctp_chunk), &sk->sk_wmem_alloc);
- sk_charge_skb(sk, chunk->skb);
+ sk->sk_wmem_queued += chunk->skb->truesize;
+ sk_mem_charge(sk, chunk->skb->truesize);
}
/* Verify that this is a valid address. */
@@ -6035,10 +6036,10 @@ static void sctp_wfree(struct sk_buff *s
atomic_sub(sizeof(struct sctp_chunk), &sk->sk_wmem_alloc);
/*
- * This undoes what is done via sk_charge_skb
+ * This undoes what is done via sctp_set_owner_w and sk_mem_charge
*/
sk->sk_wmem_queued -= skb->truesize;
- sk->sk_forward_alloc += skb->truesize;
+ sk_mem_uncharge(sk, skb->truesize);
sock_wfree(skb);
__sctp_write_space(asoc);
@@ -6059,9 +6060,9 @@ void sctp_sock_rfree(struct sk_buff *skb
atomic_sub(event->rmem_len, &sk->sk_rmem_alloc);
/*
- * Mimic the behavior of sk_stream_rfree
+ * Mimic the behavior of sock_rfree
*/
- sk->sk_forward_alloc += event->rmem_len;
+ sk_mem_uncharge(sk, event->rmem_len);
}
diff -pruN net-2.6.25-t12t19m-p3/net/sctp/ulpevent.c net-2.6.25-t12t19m-p4/net/sctp/ulpevent.c
--- net-2.6.25-t12t19m-p3/net/sctp/ulpevent.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p4/net/sctp/ulpevent.c 2007-12-29 20:59:06.000000000 -0500
@@ -700,7 +700,7 @@ struct sctp_ulpevent *sctp_ulpevent_make
if (rx_count >= asoc->base.sk->sk_rcvbuf) {
if ((asoc->base.sk->sk_userlocks & SOCK_RCVBUF_LOCK) ||
- (!sk_stream_rmem_schedule(asoc->base.sk, chunk->skb)))
+ (!sk_rmem_schedule(asoc->base.sk, chunk->skb->truesize)))
goto fail;
}
diff -pruN net-2.6.25-t12t19m-p3/net/sctp/ulpqueue.c net-2.6.25-t12t19m-p4/net/sctp/ulpqueue.c
--- net-2.6.25-t12t19m-p3/net/sctp/ulpqueue.c 2007-12-27 10:19:02.000000000 -0500
+++ net-2.6.25-t12t19m-p4/net/sctp/ulpqueue.c 2007-12-29 20:59:06.000000000 -0500
@@ -1046,7 +1046,7 @@ void sctp_ulpq_renege(struct sctp_ulpq *
sctp_ulpq_partial_delivery(ulpq, chunk, gfp);
}
- sk_stream_mem_reclaim(asoc->base.sk);
+ sk_mem_reclaim(asoc->base.sk);
return;
}
--
Hitachi Computer Products (America) Inc.
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 0/4] New interface for memory accounting (take 1)
2007-12-30 8:47 [PATCH 0/4] New interface for memory accounting (take 1) Hideo AOKI
` (3 preceding siblings ...)
2007-12-30 8:54 ` [PATCH 4/4] [SCTP]: " Hideo AOKI
@ 2007-12-31 7:34 ` David Miller
2007-12-31 15:17 ` Eric Dumazet
2007-12-31 18:46 ` Hideo AOKI
4 siblings, 2 replies; 12+ messages in thread
From: David Miller @ 2007-12-31 7:34 UTC (permalink / raw)
To: haoki
Cc: herbert, vladislav.yasevich, netdev, lksctp-developers, tyasui,
mhiramat, satoshi.oshima.fk, billfink, andi, johnpol, shemminger,
yoshfuji, yumiko.sugita.yf
From: Hideo AOKI <haoki@redhat.com>
Date: Sun, 30 Dec 2007 03:47:33 -0500
> Hello,
>
> This patch set introduces new memory accounting interface.
> Current interface is written for stream protocols only.
> To enable memory accounting in other protocols (e.g. UDP),
> I enhanced the interface and updated TCP and SCTP memory
> accounting.
>
> The patch set consists of the following 4 patches.
>
> [1/4] introducing new memory accounting interface
> [2/4] adding memory accounting points to consolidate functions
> [3/4] updating TCP to use new interface
> [4/4] updating SCTP to use new interface
>
> The patch set was tested on net-2.6.25 tree.
I like this work very much and will add this to net-2.6.25
But I will have to combine it all into one patch.
You cannot have one patch which breaks the build in any way. All of
the kernel must build properly after each patch in your patchset is
applied.
Since patch 1 renames all of the sk_stream_*() functions, TCP and SCTP
stop building.
We enforce this rule, otherwise when users try to use "git bisect" to
find out where regressions are added, they will get stuck in places
like this where the tree will not build due to such careless
changesets.
Thank you.
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 0/4] New interface for memory accounting (take 1)
2007-12-31 7:34 ` [PATCH 0/4] New interface for memory accounting (take 1) David Miller
@ 2007-12-31 15:17 ` Eric Dumazet
2007-12-31 19:03 ` Hideo AOKI
2007-12-31 23:01 ` David Miller
2007-12-31 18:46 ` Hideo AOKI
1 sibling, 2 replies; 12+ messages in thread
From: Eric Dumazet @ 2007-12-31 15:17 UTC (permalink / raw)
To: David Miller
Cc: haoki, herbert, vladislav.yasevich, netdev, lksctp-developers,
tyasui, mhiramat, satoshi.oshima.fk, billfink, andi, johnpol,
shemminger, yoshfuji, yumiko.sugita.yf
[-- Attachment #1: Type: text/plain, Size: 1645 bytes --]
David Miller a écrit :
> From: Hideo AOKI <haoki@redhat.com>
> Date: Sun, 30 Dec 2007 03:47:33 -0500
>
>> Hello,
>>
>> This patch set introduces new memory accounting interface.
>> Current interface is written for stream protocols only.
>> To enable memory accounting in other protocols (e.g. UDP),
>> I enhanced the interface and updated TCP and SCTP memory
>> accounting.
>>
>> The patch set consists of the following 4 patches.
>>
>> [1/4] introducing new memory accounting interface
>> [2/4] adding memory accounting points to consolidate functions
>> [3/4] updating TCP to use new interface
>> [4/4] updating SCTP to use new interface
>>
>> The patch set was tested on net-2.6.25 tree.
>
> I like this work very much and will add this to net-2.6.25
> But I will have to combine it all into one patch.
>
> You cannot have one patch which breaks the build in any way. All of
> the kernel must build properly after each patch in your patchset is
> applied.
>
> Since patch 1 renames all of the sk_stream_*() functions, TCP and SCTP
> stop building.
>
> We enforce this rule, otherwise when users try to use "git bisect" to
> find out where regressions are added, they will get stuck in places
> like this where the tree will not build due to such careless
> changesets.
Hi David
Could you add the following patch, because it apparently was lost
during the battle :)
Thank you
[PATCH] use SK_MEM_QUANTUM_SHIFT in __sk_mem_reclaim()
Avoid an expensive divide (as done in commit
18030477e70a826b91608aee40a987bbd368fec6 but lost in commit
23821d2653111d20e75472c8c5003df1a55309a8)
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
[-- Attachment #2: __sk_mem_reclaim.patch --]
[-- Type: text/plain, Size: 413 bytes --]
diff --git a/net/core/sock.c b/net/core/sock.c
index 8c184c4..3804e7d 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1476,7 +1476,7 @@ void __sk_mem_reclaim(struct sock *sk)
{
struct proto *prot = sk->sk_prot;
- atomic_sub(sk->sk_forward_alloc / SK_MEM_QUANTUM,
+ atomic_sub(sk->sk_forward_alloc >> SK_MEM_QUANTUM_SHIFT,
prot->memory_allocated);
sk->sk_forward_alloc &= SK_MEM_QUANTUM - 1;
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 0/4] New interface for memory accounting (take 1)
2007-12-31 15:17 ` Eric Dumazet
@ 2007-12-31 19:03 ` Hideo AOKI
2007-12-31 23:01 ` David Miller
1 sibling, 0 replies; 12+ messages in thread
From: Hideo AOKI @ 2007-12-31 19:03 UTC (permalink / raw)
To: Eric Dumazet
Cc: David Miller, herbert, vladislav.yasevich, netdev,
lksctp-developers, tyasui, mhiramat, satoshi.oshima.fk, billfink,
andi, johnpol, shemminger, yoshfuji, yumiko.sugita.yf, haoki
Eric Dumazet wrote:
> Hi David
>
> Could you add the following patch, because it apparently was lost
> during the battle :)
>
> Thank you
>
> [PATCH] use SK_MEM_QUANTUM_SHIFT in __sk_mem_reclaim()
>
> Avoid an expensive divide (as done in commit
> 18030477e70a826b91608aee40a987bbd368fec6 but lost in commit
> 23821d2653111d20e75472c8c5003df1a55309a8)
Hello Eric,
Thank you for catching this. I'm sorry about the lost.
Best regards,
Hideo
--
Hitachi Computer Products (America) Inc.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] New interface for memory accounting (take 1)
2007-12-31 15:17 ` Eric Dumazet
2007-12-31 19:03 ` Hideo AOKI
@ 2007-12-31 23:01 ` David Miller
1 sibling, 0 replies; 12+ messages in thread
From: David Miller @ 2007-12-31 23:01 UTC (permalink / raw)
To: dada1
Cc: haoki, herbert, vladislav.yasevich, netdev, lksctp-developers,
tyasui, mhiramat, satoshi.oshima.fk, billfink, andi, johnpol,
shemminger, yoshfuji, yumiko.sugita.yf
From: Eric Dumazet <dada1@cosmosbay.com>
Date: Mon, 31 Dec 2007 16:17:37 +0100
> Could you add the following patch, because it apparently was lost
> during the battle :)
>
> Thank you
>
> [PATCH] use SK_MEM_QUANTUM_SHIFT in __sk_mem_reclaim()
>
> Avoid an expensive divide (as done in commit
> 18030477e70a826b91608aee40a987bbd368fec6 but lost in commit
> 23821d2653111d20e75472c8c5003df1a55309a8)
>
>
> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Sigh :-/
Thanks for catching this Eric, patch applied.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] New interface for memory accounting (take 1)
2007-12-31 7:34 ` [PATCH 0/4] New interface for memory accounting (take 1) David Miller
2007-12-31 15:17 ` Eric Dumazet
@ 2007-12-31 18:46 ` Hideo AOKI
1 sibling, 0 replies; 12+ messages in thread
From: Hideo AOKI @ 2007-12-31 18:46 UTC (permalink / raw)
To: David Miller
Cc: herbert, vladislav.yasevich, netdev, lksctp-developers, tyasui,
mhiramat, satoshi.oshima.fk, billfink, andi, johnpol, shemminger,
yoshfuji, yumiko.sugita.yf, haoki
Hello David,
David Miller wrote:
> From: Hideo AOKI <haoki@redhat.com>
> Date: Sun, 30 Dec 2007 03:47:33 -0500
>
>> The patch set consists of the following 4 patches.
>>
>> [1/4] introducing new memory accounting interface
>> [2/4] adding memory accounting points to consolidate functions
>> [3/4] updating TCP to use new interface
>> [4/4] updating SCTP to use new interface
>
> I like this work very much and will add this to net-2.6.25
> But I will have to combine it all into one patch.
>
> You cannot have one patch which breaks the build in any way. All of
> the kernel must build properly after each patch in your patchset is
> applied.
>
> Since patch 1 renames all of the sk_stream_*() functions, TCP and SCTP
> stop building.
That's correct.
> We enforce this rule, otherwise when users try to use "git bisect" to
> find out where regressions are added, they will get stuck in places
> like this where the tree will not build due to such careless
> changesets.
Thank you for your explanation. To be honest, I didn't know the rule
exactly. I am so sorry for sending inconvenient patch set.
Best regards,
Hideo
--
Hitachi Computer Products (America) Inc.
^ permalink raw reply [flat|nested] 12+ messages in thread