Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78172
b: refs/heads/master
c: 9859a79
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Jan 28, 2008
1 parent 3ef6e97 commit d6d2ebc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3ef1355dcb8551730cc71e9ef4363f5c66ccad17
refs/heads/master: 9859a79023d71dd4e56c195a345abc4112abfd02
27 changes: 14 additions & 13 deletions trunk/net/core/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,35 +210,36 @@ 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, sk->sk_prot->memory_allocated);
atomic_add(amt, prot->memory_allocated);

/* Under limit. */
if (atomic_read(sk->sk_prot->memory_allocated) < sk->sk_prot->sysctl_mem[0]) {
if (*sk->sk_prot->memory_pressure)
*sk->sk_prot->memory_pressure = 0;
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(sk->sk_prot->memory_allocated) > sk->sk_prot->sysctl_mem[2]) {
sk->sk_prot->enter_memory_pressure();
if (atomic_read(prot->memory_allocated) > prot->sysctl_mem[2]) {
prot->enter_memory_pressure();
goto suppress_allocation;
}

/* Under pressure. */
if (atomic_read(sk->sk_prot->memory_allocated) > sk->sk_prot->sysctl_mem[1])
sk->sk_prot->enter_memory_pressure();
if (atomic_read(prot->memory_allocated) > prot->sysctl_mem[1])
prot->enter_memory_pressure();

if (kind) {
if (atomic_read(&sk->sk_rmem_alloc) < sk->sk_prot->sysctl_rmem[0])
if (atomic_read(&sk->sk_rmem_alloc) < prot->sysctl_rmem[0])
return 1;
} else if (sk->sk_wmem_queued < sk->sk_prot->sysctl_wmem[0])
} else if (sk->sk_wmem_queued < prot->sysctl_wmem[0])
return 1;

if (!*sk->sk_prot->memory_pressure ||
sk->sk_prot->sysctl_mem[2] > atomic_read(sk->sk_prot->sockets_allocated) *
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))
Expand All @@ -258,7 +259,7 @@ int sk_stream_mem_schedule(struct sock *sk, int size, int kind)

/* Alas. Undo changes. */
sk->sk_forward_alloc -= amt * SK_STREAM_MEM_QUANTUM;
atomic_sub(amt, sk->sk_prot->memory_allocated);
atomic_sub(amt, prot->memory_allocated);
return 0;
}

Expand Down

0 comments on commit d6d2ebc

Please sign in to comment.