From patchwork Sun Nov 4 22:13:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 10667169 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1042D13B5 for ; Sun, 4 Nov 2018 22:13:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1C84295F0 for ; Sun, 4 Nov 2018 22:13:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E327429610; Sun, 4 Nov 2018 22:13:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,SUBJ_OBFU_PUNCT_FEW autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8099295F0 for ; Sun, 4 Nov 2018 22:13:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59C3B6B0005; Sun, 4 Nov 2018 17:13:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 524716B0006; Sun, 4 Nov 2018 17:13:15 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39FB86B0007; Sun, 4 Nov 2018 17:13:15 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by kanga.kvack.org (Postfix) with ESMTP id C2CA86B0005 for ; Sun, 4 Nov 2018 17:13:14 -0500 (EST) Received: by mail-lj1-f200.google.com with SMTP id h12-v6so2008807ljb.12 for ; Sun, 04 Nov 2018 14:13:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:subject :to:cc:message-id:date:user-agent:mime-version:content-language :content-transfer-encoding; bh=3+9nOJfv1Giy/GsTEbrqN61DZ7j3uZOtL7gHu+ElGdU=; b=bU55RMXwudyxiJNcWdiC4B99Mzb7GTIK3TRxKfxNG7+UvV8jOK81dpor6T6Qmj5VM7 tj3IFo08xETdSqbB8Bd+2jsmn0TH4PR8y7r8WL4AFsVYaiMEfAxQn9JKWhROgocDb11g lJ/MAKgCgZmJs4KZamrPS6bttupouoW2+pr1IfK5VuHU0yOa1KSEIR4LTdGzXBIkIeU7 IPCjuptzzpnZ0oqn7eT2akZOl6oG+19pAF6q9kOi61lTwGBAg3IhWVLtMponEhJReRF1 aW7sgRA35rdxtxxjwcgSqzWxVrlX+5IXJEOFSjz4J2HYQ9O6AXJr3RrlUThNVbc4JkM5 AXaw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of vvs@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=vvs@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com X-Gm-Message-State: AGRZ1gL+gMBc2SElRQPZOIb84o1JwYj1MsW1tT89eVqbRIxnE+/A/nLI xwxmO1raDcwlh/Ohdq9SdZenDGxntGv5zorbV2aPtulMVSoQa7ur8vRBu3sbMOyAIsTfr7wJOnL dHse+O0VzNApy/PZsZwrMA5g9mF4aTLMGDApBcEKljsIny9XhNyFPGEnuQP2grg1IMg== X-Received: by 2002:a2e:2b99:: with SMTP id r25-v6mr12425235ljr.91.1541369593994; Sun, 04 Nov 2018 14:13:13 -0800 (PST) X-Google-Smtp-Source: AJdET5fQ+Cjkqz3MpjzoPG1hb5Lvjfuy2SEBHCgfLPY2zr237A49UDyb7PAvVV42OrQGQE155l6T X-Received: by 2002:a2e:2b99:: with SMTP id r25-v6mr12425215ljr.91.1541369593027; Sun, 04 Nov 2018 14:13:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541369593; cv=none; d=google.com; s=arc-20160816; b=rV8E67W3Hc8HFThLk07ZgOGDl8XBaFqlanVHlVlxEHdrAG6ZBUXTDmYAc1aj1iFu2x HnFQuBV8CATAPH4YgOBqqU/03mJroDMsHOKkAI0IXf+kvvqRY5xViJVQMmzB8ViLurD2 Rc6mKq4Jfp+cmsSo57WTYs51T5w8ydo6ueSy3rkYjgD1CBlA1LPaAuyJx3gFSm7M8OzR MkgzOfBYukBNDfDaIoYqeJ0keTossjgpxiRQvO7FSq5qLleHTf/OJXs3CMlu7xlyxh4N FhM5uQsWcRj7qLArWbKtsh4BdRnNeSgxpShpT7panpIGUFgAJPIqZOI+4isgCtNb/BRQ Yy+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version:user-agent :date:message-id:cc:to:subject:from; bh=3+9nOJfv1Giy/GsTEbrqN61DZ7j3uZOtL7gHu+ElGdU=; b=kBhn2DFIr/0EOuMdFzZe5IaSbdjAoU5WKVX8HasD/hDd/+JQ4oJwusNfTmiF4Gq6gv AVMayd925mruaHbxfJ2AohX+P+VL0W/qp3MZmtt4RXJXwpQf2qf2zpF9p8PvSABZVB9H 78Mn+jbHO6Fv7RK6GbowVfS7Cnlue5bQFp0p4IfsQ3YyeQA7ts7tU20rCeKtn5SZbNDN Fqx0Y0K4bTZOd3Zpv8EnjR2zOm6ObeiF/3VM9cLsdCmJVuV99eQFN4xY1+HAa+HzAUbn STFo0CgPl8QkTZBjSXlahvG9WfZwKkFAen1iGx2r3iSCtlqd0cRu0TnNbLDU+f3r7Usj jPoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vvs@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=vvs@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from relay.sw.ru (relay.sw.ru. [185.231.240.75]) by mx.google.com with ESMTPS id l10-v6si8931043ljj.86.2018.11.04.14.13.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Nov 2018 14:13:12 -0800 (PST) Received-SPF: pass (google.com: domain of vvs@virtuozzo.com designates 185.231.240.75 as permitted sender) client-ip=185.231.240.75; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vvs@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=vvs@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from [172.16.24.21] by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1gJQdl-00063N-Gh; Mon, 05 Nov 2018 01:13:05 +0300 From: Vasily Averin Subject: [PATCH 1/2] mm: use kvzalloc for swap_info_struct allocation To: linux-mm@kvack.org, Andrew Morton Cc: Huang Ying , linux-kernel@vger.kernel.org, Aaron Lu Message-ID: <37b60523-d085-71e9-fef9-80b90bfcef18@virtuozzo.com> Date: Mon, 5 Nov 2018 01:13:04 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP commit a2468cc9bfdf ("swap: choose swap device according to numa node") increased size of swap_info_struct up to 44 Kbytes, now it requires 4th order page. Switch to kvzmalloc allows to avoid unexpected allocation failures. Signed-off-by: Vasily Averin Acked-by: Aaron Lu --- mm/swapfile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 644f746e167a..8688ae65ef58 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2813,7 +2813,7 @@ static struct swap_info_struct *alloc_swap_info(void) unsigned int type; int i; - p = kzalloc(sizeof(*p), GFP_KERNEL); + p = kvzalloc(sizeof(*p), GFP_KERNEL); if (!p) return ERR_PTR(-ENOMEM); @@ -2824,7 +2824,7 @@ static struct swap_info_struct *alloc_swap_info(void) } if (type >= MAX_SWAPFILES) { spin_unlock(&swap_lock); - kfree(p); + kvfree(p); return ERR_PTR(-EPERM); } if (type >= nr_swapfiles) { @@ -2838,7 +2838,7 @@ static struct swap_info_struct *alloc_swap_info(void) smp_wmb(); nr_swapfiles++; } else { - kfree(p); + kvfree(p); p = swap_info[type]; /* * Do not memset this entry: a racing procfs swap_next()