[nginx] Slab: free pages statistics.

Ruslan Ermilov ru at nginx.com
Wed Dec 7 19:28:13 UTC 2016


details:   http://hg.nginx.org/nginx/rev/6e757036e588
branches:  
changeset: 6829:6e757036e588
user:      Ruslan Ermilov <ru at nginx.com>
date:      Wed Dec 07 22:25:37 2016 +0300
description:
Slab: free pages statistics.

diffstat:

 src/core/ngx_slab.c |  5 +++++
 src/core/ngx_slab.h |  1 +
 2 files changed, 6 insertions(+), 0 deletions(-)

diffs (40 lines):

diff -r 99770a5ea14f -r 6e757036e588 src/core/ngx_slab.c
--- a/src/core/ngx_slab.c	Wed Dec 07 22:25:37 2016 +0300
+++ b/src/core/ngx_slab.c	Wed Dec 07 22:25:37 2016 +0300
@@ -154,6 +154,7 @@ ngx_slab_init(ngx_slab_pool_t *pool)
     }
 
     pool->last = pool->pages + pages;
+    pool->pfree = pages;
 
     pool->log_nomem = 1;
     pool->log_ctx = &pool->zero;
@@ -691,6 +692,8 @@ ngx_slab_alloc_pages(ngx_slab_pool_t *po
             page->next = NULL;
             page->prev = NGX_SLAB_PAGE;
 
+            pool->pfree -= pages;
+
             if (--pages == 0) {
                 return page;
             }
@@ -721,6 +724,8 @@ ngx_slab_free_pages(ngx_slab_pool_t *poo
 {
     ngx_slab_page_t  *prev, *join;
 
+    pool->pfree += pages;
+
     page->slab = pages--;
 
     if (pages) {
diff -r 99770a5ea14f -r 6e757036e588 src/core/ngx_slab.h
--- a/src/core/ngx_slab.h	Wed Dec 07 22:25:37 2016 +0300
+++ b/src/core/ngx_slab.h	Wed Dec 07 22:25:37 2016 +0300
@@ -42,6 +42,7 @@ typedef struct {
     ngx_slab_page_t   free;
 
     ngx_slab_stat_t  *stats;
+    ngx_uint_t        pfree;
 
     u_char           *start;
     u_char           *end;


More information about the nginx-devel mailing list