diff options
author | zhong jiang <zhongjiang@huawei.com> | 2017-02-22 18:46:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-22 19:41:31 -0500 |
commit | f201ebd87652cf1519792f8662bb3f862c76aa33 (patch) | |
tree | 3dfc4774407bcc51d5cb91066af04cdc7eb8d3b8 | |
parent | 083fb8edda0487d192e8c117f625563b920cf7a4 (diff) |
mm/z3fold.c: limit first_num to the actual range of possible buddy indexes
At present, Tying the first_num size to NCHUNKS_ORDER is confusing. the
number of chunks is completely unrelated to the number of buddies.
The patch limits the first_num to actual range of possible buddy indexes.
and that is more reasonable and obvious without functional change.
Link: http://lkml.kernel.org/r/1476776569-29504-1-git-send-email-zhongjiang@huawei.com
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Suggested-by: Dan Streetman <ddstreet@ieee.org>
Acked-by: Dan Streetman <ddstreet@ieee.org>
Acked-by: Vitaly Wool <vitalywool@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/z3fold.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/mm/z3fold.c b/mm/z3fold.c index 8f9e89ca1d31..207e5ddc87a2 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c | |||
@@ -50,7 +50,7 @@ | |||
50 | #define ZHDR_SIZE_ALIGNED CHUNK_SIZE | 50 | #define ZHDR_SIZE_ALIGNED CHUNK_SIZE |
51 | #define NCHUNKS ((PAGE_SIZE - ZHDR_SIZE_ALIGNED) >> CHUNK_SHIFT) | 51 | #define NCHUNKS ((PAGE_SIZE - ZHDR_SIZE_ALIGNED) >> CHUNK_SHIFT) |
52 | 52 | ||
53 | #define BUDDY_MASK ((1 << NCHUNKS_ORDER) - 1) | 53 | #define BUDDY_MASK (0x3) |
54 | 54 | ||
55 | struct z3fold_pool; | 55 | struct z3fold_pool; |
56 | struct z3fold_ops { | 56 | struct z3fold_ops { |
@@ -109,7 +109,7 @@ struct z3fold_header { | |||
109 | unsigned short middle_chunks; | 109 | unsigned short middle_chunks; |
110 | unsigned short last_chunks; | 110 | unsigned short last_chunks; |
111 | unsigned short start_middle; | 111 | unsigned short start_middle; |
112 | unsigned short first_num:NCHUNKS_ORDER; | 112 | unsigned short first_num:2; |
113 | }; | 113 | }; |
114 | 114 | ||
115 | /* | 115 | /* |
@@ -179,7 +179,11 @@ static struct z3fold_header *handle_to_z3fold_header(unsigned long handle) | |||
179 | return (struct z3fold_header *)(handle & PAGE_MASK); | 179 | return (struct z3fold_header *)(handle & PAGE_MASK); |
180 | } | 180 | } |
181 | 181 | ||
182 | /* Returns buddy number */ | 182 | /* |
183 | * (handle & BUDDY_MASK) < zhdr->first_num is possible in encode_handle | ||
184 | * but that doesn't matter. because the masking will result in the | ||
185 | * correct buddy number. | ||
186 | */ | ||
183 | static enum buddy handle_to_buddy(unsigned long handle) | 187 | static enum buddy handle_to_buddy(unsigned long handle) |
184 | { | 188 | { |
185 | struct z3fold_header *zhdr = handle_to_z3fold_header(handle); | 189 | struct z3fold_header *zhdr = handle_to_z3fold_header(handle); |