Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2040345ybi; Sun, 9 Jun 2019 02:17:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyV5uO6M/pupPk3rn6SGQHuSj2BBqe7vmGjNwqpxgGXDNQFGgDCENcNQlh8kMnbGKaM2+G9 X-Received: by 2002:a17:90a:8d09:: with SMTP id c9mr15514365pjo.131.1560071870305; Sun, 09 Jun 2019 02:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560071870; cv=none; d=google.com; s=arc-20160816; b=BvXtBhfV5yx39ktaL/Ghb1hqLmiaOxku4Op/+WKcM74Ygl8qJvPCFT/EClG6dtLcYw KRwxsfZaz1nHoysD8scU3y/Mz/VsmkVWih3muwzU4ds7S1FuCP+YA072DouxENrWnKRz kdN69gqCQqhAbUS96YL+VH3VdTMTmYdtJOOzzCuCwyXhu41v9RGVNPqb51tgZIyYYlOf eV5xXvqdfG1/A10j+nIMrewzi5Tz7aksSYUFvsorLYGyGtLdZSWKr5mY99LB+cHxWMTf lpcMCXD0QYPL4mMYX/oqzUO126qZaNSwqW4ghTadc6ppSpx1T3f8MQRLQsBu3sYoQqKL JNfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=a6ykraZL2w3qugLF8FyjtO6T7aloAveG26BZNEMnWFY=; b=t5ML/w5QaQEKjRKRPwbiEsiqMx2yQQ+6WcklV6/kK+J7jdp65B8knRCuorotBCP4K6 qK0sN2UKOxJHlXGZuMvX4mXREKWqrq8u58Ph7NWAVKDnJvGoFGkq6sb/pNMs6VzMR4jz jc/YYrwfdyBPT5oac+sGzOFApMGroBktlRvbtFfB2HIU3kYyGYVtoy5L/SQd5lXqd0O8 fHpYahNJSyU56HRazbDDog6+XQKqShYBg/8n5v9Ro4/ooNegQrGjhanPHR5T/tfGcZn3 JAJeTIeaJmuTPtN4fESvdp/KYCR7l4oAIqvN0wzGQqbX7xjdMKifZ3L6wYGRzBPNJvzS qlcQ== 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 t5si3833445pgp.296.2019.06.09.02.17.34; Sun, 09 Jun 2019 02:17:50 -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 S1727977AbfFIJQa (ORCPT + 99 others); Sun, 9 Jun 2019 05:16:30 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:18117 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726686AbfFIJQa (ORCPT ); Sun, 9 Jun 2019 05:16:30 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 714EED491E95A3D71315; Sun, 9 Jun 2019 17:16:18 +0800 (CST) Received: from use12-sp2.huawei.com (10.67.188.190) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Sun, 9 Jun 2019 17:16:08 +0800 From: ChenGang To: , , , , CC: , , , , , , ChenGang Subject: [PATCH] mm: align up min_free_kbytes to multipy of 4 Date: Sun, 9 Jun 2019 17:10:28 +0800 Message-ID: <1560071428-24267-1-git-send-email-cg.chen@huawei.com> X-Mailer: git-send-email 1.8.5.6 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.188.190] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Usually the value of min_free_kbytes is multiply of 4, and in this case ,the right shift is ok. But if it's not, the right-shifting operation will lose the low 2 bits, and this cause kernel don't reserve enough memory. So it's necessary to align the value of min_free_kbytes to multiply of 4. For example, if min_free_kbytes is 64, then should keep 16 pages, but if min_free_kbytes is 65 or 66, then should keep 17 pages. Signed-off-by: ChenGang --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d66bc8a..1baeeba 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7611,7 +7611,8 @@ static void setup_per_zone_lowmem_reserve(void) static void __setup_per_zone_wmarks(void) { - unsigned long pages_min = min_free_kbytes >> (PAGE_SHIFT - 10); + unsigned long pages_min = + (PAGE_ALIGN(min_free_kbytes * 1024) / 1024) >> (PAGE_SHIFT - 10); unsigned long lowmem_pages = 0; struct zone *zone; unsigned long flags; -- 1.8.5.6