Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932312AbaJNMBq (ORCPT ); Tue, 14 Oct 2014 08:01:46 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:39534 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755248AbaJNL7y (ORCPT ); Tue, 14 Oct 2014 07:59:54 -0400 X-AuditID: cbfee68d-f79296d000004278-d9-543d103847b1 From: Heesub Shin To: Andrew Morton , Seth Jennings Cc: Nitin Gupta , Dan Streetman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sunae Seo , Heesub Shin Subject: [RFC PATCH 1/9] mm/zbud: tidy up a bit Date: Tue, 14 Oct 2014 20:59:20 +0900 Message-id: <1413287968-13940-2-git-send-email-heesub.shin@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1413287968-13940-1-git-send-email-heesub.shin@samsung.com> References: <1413287968-13940-1-git-send-email-heesub.shin@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRmVeSWpSXmKPExsVy+t8zTV0LAdsQg11dPBZz1q9hs3h5SNPi QttuFouDs5cwWVzeNYfN4t6a/6wWG1pmsVt8OvqIzaJx9zs2B06PpxMOMnls+jSJ3ePEjN8s Hn1bVjF6XP9W5LHz02ZWj8+b5ALYo7hsUlJzMstSi/TtErgypvYuZy64KFbR/HwRWwPjN8Eu Rk4OCQETiRufDjNC2GISF+6tZwOxhQSWMUr09ibA1Fz89Jq9i5ELKL6IUeLvhw5mCKedSaLh 7xsgh4ODTUBb4tC2YJAGEYFIie0PP7KA1DALHGOU2HbvGStIQlhAX+Lq236wbSwCqhLHTi1h BrF5BdwlLu+dxAaxTU7i5LHJYPWcAh4SS2bvYIG4yF3i/Ox+JpChEgK72CUmLVjMBjFIQOLb 5EMsIEdICMhKbDrADDFHUuLgihssExiFFzAyrGIUTS1ILihOSi8y1CtOzC0uzUvXS87P3cQI iYXeHYy3D1gfYhTgYFT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XtXpok97RufaKvo8rlF0KLC1P32j1/yv1u/xzn/qwN/8t4l9wq viIrNyN6Y4bMpbeHQta/C7/XqNafnDFD7EWA6cM5h2fnLdLe1H/8zHnPafZrYlaU3vt6UrBB um2FEktxRqKhFnNRcSIAj2yZMssCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For aesthetics, add a blank line between functions, remove useless initialization statements, and simplify codes a bit. No functional differences are introduced. Signed-off-by: Heesub Shin --- mm/zbud.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mm/zbud.c b/mm/zbud.c index ecf1dbe..6f36394 100644 --- a/mm/zbud.c +++ b/mm/zbud.c @@ -145,6 +145,7 @@ static int zbud_zpool_malloc(void *pool, size_t size, gfp_t gfp, { return zbud_alloc(pool, size, gfp, handle); } + static void zbud_zpool_free(void *pool, unsigned long handle) { zbud_free(pool, handle); @@ -174,6 +175,7 @@ static void *zbud_zpool_map(void *pool, unsigned long handle, { return zbud_map(pool, handle); } + static void zbud_zpool_unmap(void *pool, unsigned long handle) { zbud_unmap(pool, handle); @@ -350,16 +352,11 @@ int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp, spin_lock(&pool->lock); /* First, try to find an unbuddied zbud page. */ - zhdr = NULL; for_each_unbuddied_list(i, chunks) { if (!list_empty(&pool->unbuddied[i])) { zhdr = list_first_entry(&pool->unbuddied[i], struct zbud_header, buddy); list_del(&zhdr->buddy); - if (zhdr->first_chunks == 0) - bud = FIRST; - else - bud = LAST; goto found; } } @@ -372,13 +369,15 @@ int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp, spin_lock(&pool->lock); pool->pages_nr++; zhdr = init_zbud_page(page); - bud = FIRST; found: - if (bud == FIRST) + if (zhdr->first_chunks == 0) { zhdr->first_chunks = chunks; - else + bud = FIRST; + } else { zhdr->last_chunks = chunks; + bud = LAST; + } if (zhdr->first_chunks == 0 || zhdr->last_chunks == 0) { /* Add to unbuddied list */ @@ -433,7 +432,7 @@ void zbud_free(struct zbud_pool *pool, unsigned long handle) /* Remove from existing buddy list */ list_del(&zhdr->buddy); - if (zhdr->first_chunks == 0 && zhdr->last_chunks == 0) { + if (num_free_chunks(zhdr) == NCHUNKS) { /* zbud page is empty, free */ list_del(&zhdr->lru); free_zbud_page(zhdr); @@ -489,7 +488,7 @@ int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries) { int i, ret, freechunks; struct zbud_header *zhdr; - unsigned long first_handle = 0, last_handle = 0; + unsigned long first_handle, last_handle; spin_lock(&pool->lock); if (!pool->ops || !pool->ops->evict || list_empty(&pool->lru) || @@ -529,7 +528,7 @@ int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries) next: spin_lock(&pool->lock); zhdr->under_reclaim = false; - if (zhdr->first_chunks == 0 && zhdr->last_chunks == 0) { + if (num_free_chunks(zhdr) == NCHUNKS) { /* * Both buddies are now free, free the zbud page and * return success. -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/