From mboxrd@z Thu Jan 1 00:00:00 1970 From: Changli Gao Subject: Re: [RFC] mm: generic adaptive large memory allocation APIs Date: Thu, 6 May 2010 11:22:03 +0800 Message-ID: References: <1273105838-4441-1-git-send-email-xiaosuo@gmail.com> <201005060312.o463CUOQ085547@www262.sakura.ne.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: eric.dumazet@gmail.com, jslaby@suse.cz, viro@zeniv.linux.org.uk, paulmck@linux.vnet.ibm.com, adobriyan@gmail.com, mingo@elte.hu, peterz@infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, avi@redhat.com, akpm@linux-foundation.org To: Tetsuo Handa Return-path: Received: from mail-px0-f174.google.com ([209.85.212.174]:32844 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751639Ab0EFDWX convert rfc822-to-8bit (ORCPT ); Wed, 5 May 2010 23:22:23 -0400 In-Reply-To: <201005060312.o463CUOQ085547@www262.sakura.ne.jp> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 2010/5/6 Tetsuo Handa : > Changli Gao wrote: >> struct kvfree_work_struct { >> =C2=A0 =C2=A0 =C2=A0 struct work_struct =C2=A0 =C2=A0 =C2=A0work; >> =C2=A0 =C2=A0 =C2=A0 void =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0*head; >> =C2=A0 =C2=A0 =C2=A0 void =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0**ptail; >> }; > > I wonder why "struct kvfree_work_struct" is needed. > According to http://kernel.ubuntu.com/git?p=3Djj/ubuntu-lucid.git;a=3D= blobdiff;f=3Dsecurity/apparmor/match.c;h=3Dd2cd55419acfcae85cb748c8f837= a4384a3a0d29;hp=3Dafc2dd2260edffcf88521ae86458ad03aa8ea12c;hb=3Df5eba4b= 0a01cc671affa429ba1512b6de7caeb5b;hpb=3Dabdff9ddaf2644d0f9962490f73e030= 806ba90d3 , > > static void kvfree_work(struct work_struct *work) > { > =C2=A0 =C2=A0 =C2=A0 =C2=A0vfree(work); > } > > void kvfree_inatomic(void *ptr, size_t size) > { > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (size < PAGE_SIZE) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0kfree(ptr); > =C2=A0 =C2=A0 =C2=A0 =C2=A0} else if (is_vmalloc_addr(ptr)) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * We can embe= d "struct work_struct" inside *ptr > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * because siz= e >=3D PAGE_SIZE. > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 */ > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct work_st= ruct *work =3D ptr; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0BUILD_BUG_ON(s= izeof(struct work_struct) > PAGE_SIZE); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0INIT_WORK(&wor= k, kvfree_work); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0schedule_work(= &work); &work should be work. It is a much better idea. thanks very much. > =C2=A0 =C2=A0 =C2=A0 =C2=A0} else { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0free_pages_exa= ct(ptr, size); > =C2=A0 =C2=A0 =C2=A0 =C2=A0} > } > > should do what you want. (Though, I didn't test it.) > --=20 Regards=EF=BC=8C Changli Gao(xiaosuo@gmail.com) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html