Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp470418ima; Fri, 26 Oct 2018 01:03:30 -0700 (PDT) X-Google-Smtp-Source: AJdET5fGUW+QI75tvHDlsoLUEvp17OtQ2+jUilOnwvj2K96hyKat8MIFmKBM2xnTtfMnp+Txp/K+ X-Received: by 2002:a62:8c0d:: with SMTP id m13-v6mr2635682pfd.207.1540541010744; Fri, 26 Oct 2018 01:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540541010; cv=none; d=google.com; s=arc-20160816; b=BJe7Xgg4eqWexSX5qVjQfiQxpWF32+C6A4Fv60KAob863YAA22hlBlKATMlBtTFqI8 AtEn3759+Yr98Upu6mt1ehNzs6t2AulA+8EKQJMZGxtDaKkpqTrPuKkiTbrDUKVvo65j MylU8GO47zs63i/F2XuEO5GoqpxsHfjyWUjrWERe6pWBhsvOz/LQ4KjpQoTk4vYPZM1j awCt0wPATwYroqkF6t3ytkGqux01RxwLMFUMBurBNtRjFBUz//sJUzRe+lXp/YYSTeZP WqIZZFnOnKui5vR6cLlvuwIoGO0qjBRbkQWHfL7jAWqmhSK9zUgwoZM34/ROD6HeGfau ltTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=xBYWh2f40QZiFnqBvPnsIVoQOgHyV2lkGIRdrzMd1Sg=; b=ckn9g/97lz5f31NKdh+cNFyPT0Qj2pMYvtke4wco8kPWCd0LvNtoqeVdKvzvg3mi2P EjX2bypPk9FrwretT1yIevdgaZTwCKZvtdvlBy7ZgMcArMbK8NwIJAs8UlBKcNkk0Va/ jOlGyluClCLvFSABayhVl3Ork/rw7e+z2jX8rBfcq1fUIsM67XywFyFa9wReLewGdnbX qQJm8Yw4ymddFDG6iGt2WjhwK/9EIKA9hfQvgZwy0qGiga6yvpg6TZIgMI/6w21nQR4r oYvb67Xd83kw+vKpjCgzQrHQ21cJjOqZ1lMCl2XrzOVNL2ypGARlpnkpsW7NMleL5k/d QGig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s186-v6si1893253pfb.129.2018.10.26.01.03.14; Fri, 26 Oct 2018 01:03:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726348AbeJZQha (ORCPT + 99 others); Fri, 26 Oct 2018 12:37:30 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:40010 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726003AbeJZQha (ORCPT ); Fri, 26 Oct 2018 12:37:30 -0400 X-UUID: a3b009def0ae443e84f16d830024f0b0-20181026 X-UUID: a3b009def0ae443e84f16d830024f0b0-20181026 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 426055461; Fri, 26 Oct 2018 16:01:08 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 26 Oct 2018 16:01:07 +0800 Received: from [172.21.77.33] (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 26 Oct 2018 16:01:07 +0800 Message-ID: <1540540867.21297.2.camel@mtkswgap22> Subject: Re: [PATCH] mm/page_owner: use vmalloc instead of kmalloc From: Miles Chen To: Joe Perches CC: Matthias Brugger , , , , , Date: Fri, 26 Oct 2018 16:01:07 +0800 In-Reply-To: References: <1540492481-4144-1-git-send-email-miles.chen@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2018-10-25 at 11:44 -0700, Joe Perches wrote: > On Fri, 2018-10-26 at 02:34 +0800, miles.chen@mediatek.com wrote: > > From: Miles Chen > > > > The kbuf used by page owner is allocated by kmalloc(), > > which means it can use only normal memory and there might > > be a "out of memory" issue when we're out of normal memory. > > > > Use vmalloc() so we can also allocate kbuf from highmem > > on 32bit kernel. > > If this is really necessary, using kvmalloc/kvfree would > be better as the vmalloc space is also limited. thanks for the advise. kvmalloc/kvfree is better here. > > > diff --git a/mm/page_owner.c b/mm/page_owner.c > [] > > @@ -1,7 +1,6 @@ > > // SPDX-License-Identifier: GPL-2.0 > > #include > > #include > > -#include > > #include > > #include > > #include > > @@ -10,6 +9,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "internal.h" > > > > @@ -351,7 +351,7 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, > > .skip = 0 > > }; > > > > - kbuf = kmalloc(count, GFP_KERNEL); > > + kbuf = vmalloc(count); > > if (!kbuf) > > return -ENOMEM; > > > > @@ -397,11 +397,11 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, > > if (copy_to_user(buf, kbuf, ret)) > > ret = -EFAULT; > > > > - kfree(kbuf); > > + vfree(kbuf); > > return ret; > > > > err: > > - kfree(kbuf); > > + vfree(kbuf); > > return -ENOMEM; > > } > > >