]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: nvmap: add handle share count to debug stats
authorKrishna Reddy <vdumpa@nvidia.com>
Fri, 20 Jun 2014 00:34:01 +0000 (17:34 -0700)
committerKrishna Reddy <vdumpa@nvidia.com>
Fri, 20 Jun 2014 16:39:57 +0000 (09:39 -0700)
handle share count provides info on how many processes are sharing
the handle. IOW, how many processes are holding a ref on handle.
Update the comments for umap/kmap_count.

Change-Id: I9f543ebf51842dad6ecd3bfeb7480496c98963be
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/426302

drivers/video/tegra/nvmap/nvmap_dev.c
drivers/video/tegra/nvmap/nvmap_handle.c
drivers/video/tegra/nvmap/nvmap_priv.h

index d3e1230a0022d32bd38514f9618ce4ab7ae44908..3e4f50671cdaba4b487f40bf6a359835368e9c17 100644 (file)
@@ -448,6 +448,7 @@ static void destroy_client(struct nvmap_client *client)
 
                dma_buf_put(ref->handle->dmabuf);
                rb_erase(&ref->node, &client->handle_refs);
+               atomic_dec(&ref->handle->share_count);
 
                dupes = atomic_read(&ref->dupes);
                while (dupes--)
@@ -828,7 +829,7 @@ static void allocations_stringify(struct nvmap_client *client,
                        phys_addr_t base = iovmm ? 0 :
                                           (handle->carveout->base);
                        seq_printf(s,
-                               "%-18s %-18s %8llx %10zuK %8x %6u %6u %6u %6u %6u %8p\n",
+                               "%-18s %-18s %8llx %10zuK %8x %6u %6u %6u %6u %6u %6u %8p\n",
                                "", "",
                                (unsigned long long)base, K(handle->size),
                                handle->userflags,
@@ -837,6 +838,7 @@ static void allocations_stringify(struct nvmap_client *client,
                                atomic_read(&ref->pin),
                                atomic_read(&handle->kmap_count),
                                atomic_read(&handle->umap_count),
+                               atomic_read(&handle->share_count),
                                handle);
                }
        }
@@ -852,9 +854,9 @@ static int nvmap_debug_allocations_show(struct seq_file *s, void *unused)
        spin_lock(&node->clients_lock);
        seq_printf(s, "%-18s %18s %8s %11s\n",
                "CLIENT", "PROCESS", "PID", "SIZE");
-       seq_printf(s, "%-18s %18s %8s %11s %8s %6s %6s %6s %6s %6s %8s\n",
+       seq_printf(s, "%-18s %18s %8s %11s %8s %6s %6s %6s %6s %6s %6s %8s\n",
                        "", "", "BASE", "SIZE", "FLAGS", "REFS",
-                       "DUPES", "PINS", "KMAPS", "UMAPS", "UID");
+                       "DUPES", "PINS", "KMAPS", "UMAPS", "SHARE", "UID");
        list_for_each_entry(commit, &node->clients, list) {
                struct nvmap_client *client =
                        get_client_from_carveout_commit(node, commit);
@@ -973,9 +975,9 @@ static int nvmap_debug_iovmm_allocations_show(struct seq_file *s, void *unused)
        spin_lock(&dev->clients_lock);
        seq_printf(s, "%-18s %18s %8s %11s\n",
                "CLIENT", "PROCESS", "PID", "SIZE");
-       seq_printf(s, "%-18s %18s %8s %11s %8s %6s %6s %6s %6s %6s %8s\n",
+       seq_printf(s, "%-18s %18s %8s %11s %8s %6s %6s %6s %6s %6s %6s %8s\n",
                        "", "", "BASE", "SIZE", "FLAGS", "REFS",
-                       "DUPES", "PINS", "KMAPS", "UMAPS", "UID");
+                       "DUPES", "PINS", "KMAPS", "UMAPS", "SHARE", "UID");
        list_for_each_entry(client, &dev->clients, list) {
                int iovm_commit = atomic_read(&client->iovm_commit);
                client_stringify(client, s);
index 742eac3f53c7f27d84ad4d77cadee78f127f0feb..67cad8a1bf35a5ac8f8acd1b73e6fec2945e404b 100644 (file)
@@ -424,6 +424,7 @@ void nvmap_free_handle(struct nvmap_client *client,
        pins = atomic_read(&ref->pin);
        rb_erase(&ref->node, &client->handle_refs);
        client->handle_count--;
+       atomic_dec(&ref->handle->share_count);
 
        if (h->alloc && h->heap_pgalloc)
                atomic_sub(h->size, &client->iovm_commit);
@@ -484,6 +485,7 @@ static void add_handle_ref(struct nvmap_client *client,
        client->handle_count++;
        if (client->handle_count > nvmap_max_handle_count)
                nvmap_max_handle_count = client->handle_count;
+       atomic_inc(&ref->handle->share_count);
        nvmap_ref_unlock(client);
 }
 
index e5cd460f0a62d0399bb285d3844f53b790d66f8c..1e862710cfbb07e2cafd641ad82ac3be14d3e699 100644 (file)
@@ -129,8 +129,9 @@ struct nvmap_handle {
        u32 userflags;          /* flags passed from userspace */
        void *vaddr;            /* mapping used inside kernel */
        struct list_head vmas;  /* list of all user vma's */
-       atomic_t umap_count;    /* number of mapping from user space */
-       atomic_t kmap_count;    /* number of mappings from kernel space */
+       atomic_t umap_count;    /* number of outstanding maps from user */
+       atomic_t kmap_count;    /* number of outstanding map from kernel */
+       atomic_t share_count;   /* number of processes sharing the handle */
        struct list_head lru;   /* list head to track the lru */
        struct mutex lock;
        void *nvhost_priv;      /* nvhost private data */