Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755414Ab2BFR1E (ORCPT ); Mon, 6 Feb 2012 12:27:04 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:38311 "EHLO e9.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754033Ab2BFR1C (ORCPT ); Mon, 6 Feb 2012 12:27:02 -0500 Message-ID: <4F300D41.5050105@linux.vnet.ibm.com> Date: Mon, 06 Feb 2012 11:26:25 -0600 From: Seth Jennings User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111229 Thunderbird/9.0 MIME-Version: 1.0 To: Dave Hansen CC: Greg Kroah-Hartman , Nitin Gupta , Dan Magenheimer , Brian King , Konrad Wilk , linux-mm@kvack.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] staging: zsmalloc: zsmalloc memory allocation library References: <1326149520-31720-1-git-send-email-sjenning@linux.vnet.ibm.com> <1326149520-31720-2-git-send-email-sjenning@linux.vnet.ibm.com> <4F21A5AF.6010605@linux.vnet.ibm.com> In-Reply-To: <4F21A5AF.6010605@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12020617-7182-0000-0000-000000B172A3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2093 Lines: 55 On 01/26/2012 01:12 PM, Dave Hansen wrote: > On 01/09/2012 02:51 PM, Seth Jennings wrote: >> + area = &get_cpu_var(zs_map_area); >> + if (off + class->size <= PAGE_SIZE) { >> + /* this object is contained entirely within a page */ >> + area->vm_addr = kmap_atomic(page); >> + } else { >> + /* this object spans two pages */ >> + struct page *nextp; >> + >> + nextp = get_next_page(page); >> + BUG_ON(!nextp); >> + >> + >> + set_pte(area->vm_ptes[0], mk_pte(page, PAGE_KERNEL)); >> + set_pte(area->vm_ptes[1], mk_pte(nextp, PAGE_KERNEL)); >> + >> + /* We pre-allocated VM area so mapping can never fail */ >> + area->vm_addr = area->vm->addr; >> + } > > This bit appears to be trying to make kmap_atomic() variant that can map > two pages in to contigious virtual addresses. Instead of open-coding it > in a non-portable way like this, should we just make a new kmap_atomic() > variant that does this? > > From the way it's implemented, I _think_ you're guaranteed to get two > contiguous addresses if you do two adjacent kmap_atomics() on the same CPU: > > void *kmap_atomic_prot(struct page *page, pgprot_t prot) > { > ... > type = kmap_atomic_idx_push(); > idx = type + KM_TYPE_NR*smp_processor_id(); > vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); > > I think if you do a get_cpu()/put_cpu() or just a preempt_disable() > across the operations you'll be guaranteed to get two contiguous addresses. I'm not quite following here. kmap_atomic() only does this for highmem pages. For normal pages (all pages for 64-bit), it doesn't do any mapping at all. It just returns the virtual address of the page since it is in the kernel's address space. For this design, the pages _must_ be mapped, even if the pages are directly reachable in the address space, because they must be virtually contiguous. -- Seth -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/