From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755867AbbIBQ73 (ORCPT ); Wed, 2 Sep 2015 12:59:29 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:36684 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755655AbbIBQ7Z (ORCPT ); Wed, 2 Sep 2015 12:59:25 -0400 Date: Wed, 2 Sep 2015 18:59:22 +0200 From: Ingo Molnar To: Jan Beulich Cc: Andy Lutomirski , David Vrabel , Ingo Molnar , Thomas Gleixner , Boris Ostrovsky , Konrad Rzeszutek Wilk , "linux-kernel@vger.kernel.org" , "H. Peter Anvin" Subject: Re: [PATCH v2] x86: fix small LDT allocation for Xen Message-ID: <20150902165922.GA5959@gmail.com> References: <55E70BC2020000780009EF6C@prv-mh.provo.novell.com> <55E7347D020000780009F1DA@prv-mh.provo.novell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55E7347D020000780009F1DA@prv-mh.provo.novell.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Jan Beulich wrote: > >> @@ -95,7 +95,7 @@ static void free_ldt_struct(struct ldt_s > >> if (ldt->size * LDT_ENTRY_SIZE > PAGE_SIZE) > >> vfree(ldt->entries); > >> else > >> - kfree(ldt->entries); > >> + put_page(virt_to_page(ldt->entries)); > > > > FWIW, I'm not convinced this is or was correct. Using free_page looks > > a bit safer, and free_page does more than just put_page. > > Actually I agree. put_page() is meant to be paired with get_page(); > __get_free_pages() is just misleading (i.e. doesn't imply a get_page()) > and instead is to be paired with free_pages(). Will do a v3 then. So put_page() is a page cache primitive and should not be used outside of it. As it happens, it is safe to put_page() a regularly allocated page as well, but it's a little bit slower than doing a free_page(). Thanks, Ingo