Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933762AbcCOGuo (ORCPT ); Tue, 15 Mar 2016 02:50:44 -0400 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:37526 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753727AbcCOGug (ORCPT ); Tue, 15 Mar 2016 02:50:36 -0400 X-Original-SENDERIP: 156.147.1.125 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 165.244.98.203 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 10.177.223.161 X-Original-MAILFROM: minchan@kernel.org Date: Tue, 15 Mar 2016 15:51:26 +0900 From: Minchan Kim To: Sergey Senozhatsky CC: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, jlayton@poochiereds.net, bfields@fieldses.org, Vlastimil Babka , Joonsoo Kim , koct9i@gmail.com, aquini@redhat.com, virtualization@lists.linux-foundation.org, Mel Gorman , Hugh Dickins , Sergey Senozhatsky , rknize@motorola.com, Rik van Riel , Gioh Kim Subject: Re: [PATCH v1 11/19] zsmalloc: squeeze freelist into page->mapping Message-ID: <20160315065126.GA3039@bbox> References: <1457681423-26664-1-git-send-email-minchan@kernel.org> <1457681423-26664-12-git-send-email-minchan@kernel.org> <20160315064053.GF1464@swordfish> MIME-Version: 1.0 In-Reply-To: <20160315064053.GF1464@swordfish> User-Agent: Mutt/1.5.21 (2010-09-15) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB08/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/03/15 15:50:33, Serialize by Router on LGEKRMHUB08/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/03/15 15:50:33, Serialize complete at 2016/03/15 15:50:33 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1436 Lines: 51 On Tue, Mar 15, 2016 at 03:40:53PM +0900, Sergey Senozhatsky wrote: > On (03/11/16 16:30), Minchan Kim wrote: > > -static void *location_to_obj(struct page *page, unsigned long obj_idx) > > +static void objidx_to_page_and_ofs(struct size_class *class, > > + struct page *first_page, > > + unsigned long obj_idx, > > + struct page **obj_page, > > + unsigned long *ofs_in_page) > > this looks big; 5 params, function "returning" both page and offset... > any chance to split it in two steps, perhaps? Yes, it's rather ugly but I don't have a good idea. Feel free to suggest if you have a better idea. > > besides, it is more intuitive (at least to me) when 'offset' > shortened to 'offt', not 'ofs'. Indeed. I will change it to get_page_and_offset instead of abbreviation if we cannot refactor it more. > > -ss > > > { > > - unsigned long obj; > > + int i; > > + unsigned long ofs; > > + struct page *cursor; > > + int nr_page; > > > > - if (!page) { > > - VM_BUG_ON(obj_idx); > > - return NULL; > > - } > > + ofs = obj_idx * class->size; > > + cursor = first_page; > > + nr_page = ofs >> PAGE_SHIFT; > > > > - obj = page_to_pfn(page) << OBJ_INDEX_BITS; > > - obj |= ((obj_idx) & OBJ_INDEX_MASK); > > - obj <<= OBJ_TAG_BITS; > > + *ofs_in_page = ofs & ~PAGE_MASK; > > + > > + for (i = 0; i < nr_page; i++) > > + cursor = get_next_page(cursor); > > > > - return (void *)obj; > > + *obj_page = cursor; > > }