Messages in this thread | | | From | Dan Streetman <> | Date | Tue, 22 Sep 2015 13:09:09 -0400 | Subject | Re: [PATCH 1/2] zbud: allow PAGE_SIZE allocations |
| |
On Tue, Sep 22, 2015 at 6:18 AM, Vitaly Wool <vitalywool@gmail.com> wrote: > Hi Dan, > > On Mon, Sep 21, 2015 at 6:17 PM, Dan Streetman <ddstreet@ieee.org> wrote: >> Please make sure to cc Seth also, he's the owner of zbud. > > Sure :) > > <snip> >>> @@ -514,8 +552,17 @@ int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries) >>> return -EINVAL; >>> } >>> for (i = 0; i < retries; i++) { >>> - zhdr = list_tail_entry(&pool->lru, struct zbud_header, lru); >>> - list_del(&zhdr->lru); >>> + page = list_tail_entry(&pool->lru, struct page, lru); >>> + zhdr = page_address(page); >>> + list_del(&page->lru); >>> + /* Uncompressed zbud page? just run eviction and free it */ >>> + if (page->flags & PG_uncompressed) { >>> + page->flags &= ~PG_uncompressed; >>> + spin_unlock(&pool->lock); >>> + pool->ops->evict(pool, encode_handle(zhdr, FULL)); >>> + __free_page(page); >>> + return 0; >> >> again, don't be redundant. change the function to handle full-sized >> pages, don't repeat the function in an if() block for a special case. > > Well, this case is a little tricky. How to process a zbud page in > zbud_reclaim_page() is defined basing on the assumption there is a > zhdr at the beginning of the page. What can be done here IMV is either > of the following:
aha, this is why you used the page flag.
> * add a constant magic number to zhdr and check for it, if the check > fails, it is a type FULL page > * add a CRC field to zhdr, if CRC check over assumed zhdr fails, it > is a type FULL page
neither of those; you can't guarantee the magic number won't naturally occur in a page.
> * use a field from struct page to indicate its type
sure, you could use a pre-existing field from struct page, like the page->private field.
> > The last option still looks better to me. > > ~vitaly
| |