Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754874AbbLIOH5 (ORCPT ); Wed, 9 Dec 2015 09:07:57 -0500 Received: from mail1.bemta12.messagelabs.com ([216.82.251.8]:25118 "EHLO mail1.bemta12.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754118AbbLIOH4 (ORCPT ); Wed, 9 Dec 2015 09:07:56 -0500 X-Env-Sender: Marc_Gonzalez@sigmadesigns.com X-Msg-Ref: server-2.tower-219.messagelabs.com!1449670072!15718851!1 X-Originating-IP: [195.215.56.170] X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Subject: Re: m(un)map kmalloc buffers to userspace To: Michal Hocko CC: Sebastian Frias , linux-mm , LKML References: <5667128B.3080704@sigmadesigns.com> <20151209135544.GE30907@dhcp22.suse.cz> From: Marc Gonzalez Message-ID: <566835B6.9010605@sigmadesigns.com> Date: Wed, 9 Dec 2015 15:07:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39 MIME-Version: 1.0 In-Reply-To: <20151209135544.GE30907@dhcp22.suse.cz> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [172.27.0.114] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 997 Lines: 29 On 09/12/2015 14:55, Michal Hocko wrote: > On Tue 08-12-15 18:25:31, Sebastian Frias wrote: >> Hi, >> >> We are porting a driver from Linux 3.4.39+ to 4.1.13+, CPU is Cortex-A9. >> >> The driver maps kmalloc'ed memory to user space. > > This sounds like a terrible idea to me. Why don't you simply use the > page allocator directly? Try to imagine what would happen if you mmaped > a kmalloc with a size which is not page aligned? mmaped memory uses > whole page granularity. According to the source code, this kernel module calls kmalloc(1 << 17, GFP_KERNEL | __GFP_REPEAT); I suppose kmalloc() would return page-aligned memory? (Note: the kernel module was originally written for 2.4 and was updated inconsistently over the years.) Regards. -- 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/