From patchwork Mon Nov 5 11:17:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 10667833 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 23F4B14BD for ; Mon, 5 Nov 2018 11:17:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EB532919E for ; Mon, 5 Nov 2018 11:17:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2F9A29556; Mon, 5 Nov 2018 11:17:10 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 7D2FC2919E for ; Mon, 5 Nov 2018 11:17:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E87F6B0007; Mon, 5 Nov 2018 06:17:09 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 76EF66B0008; Mon, 5 Nov 2018 06:17:09 -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 637A26B000C; Mon, 5 Nov 2018 06:17:09 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by kanga.kvack.org (Postfix) with ESMTP id E96B66B0007 for ; Mon, 5 Nov 2018 06:17:08 -0500 (EST) Received: by mail-lj1-f197.google.com with SMTP id c24-v6so2554811lja.1 for ; Mon, 05 Nov 2018 03:17:08 -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:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=sf5xiWMLH6yrahkmqzkUjL0nc86L0NvxA/q4iIiAZEg=; b=nYJ3gGqvLeCQ+Sjens5PUt60Ru2r2EKR3GxuSVJORUt6RNaI9geBEh+C6Q8HujyjWw yM18rWyW1/DxL+fdjM4Tn6o4P55bWokl40XmjYSAUA3zo0jNLIRztVobyiG+qJ6mNPb9 ZqbeIIkRbU7d6opbdJ55WMZ+h5RpRTO4rk+qThrkWYOropUpzs3/lj4mRbfDZdJA0WAS xMYQXj+L9DkIj1AjLKTeQJCXdw6n3VosM/380R2G65Lsk44r8H3DUaJ83f+Ub/DzV8ze 2Cd1t82ZjRdlse+9U/47mcZRP3EaUGp9n0Ak5D+RNz9oPNzInoQQnvjm4ovUdslQ6Wo4 dNzg== 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: AGRZ1gJsFu7Meu+cOUASeeid/RPET1WizQMMJhqKyHUdR/qTb9Evi9Gk WAufVdZ+4Ig+GJBBGADBZwtEHip2I5clQQSIlMM+S7gFwbG1+PXGEqxKAUyq+52IOQznHFW0B6C b/FbY2GLSySgVfZPI8IjsCTC2vjRl7lBvBuuUWJdmgNMi7GYljXLLAYTYdiGtHFc5Sw== X-Received: by 2002:a19:48d0:: with SMTP id v199mr12688827lfa.104.1541416628375; Mon, 05 Nov 2018 03:17:08 -0800 (PST) X-Google-Smtp-Source: AJdET5cEmw4I8dQUfw81Jt34FyizS8Sdwjmnz5LSZul4W3l1Lm3qG75P0XRDjhgQlZ77+FtjXiE8 X-Received: by 2002:a19:48d0:: with SMTP id v199mr12688791lfa.104.1541416627430; Mon, 05 Nov 2018 03:17:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541416627; cv=none; d=google.com; s=arc-20160816; b=jA8p6/KhF4ufSAUKDbXHzusyC2V2RTDNDnD9JFHAAmfAnHfRNBJJ3Qn+Gx+hysTEHM oAVzPl0M7IuXIT1ohBxnfmgupXQMN5/M4C4/liiB9w9ri52+0RRz3W/qs2jrdsnviVLu HOVU2IkgIHyeHEvwXZAXBZYV8SXTHO5FmLOoi02dCK31oOuce5HJDsOPWIeRmq5ig8Wk YqQ59Mj33ri9EFceZQpOiuB9DTzEYv0hXL38RCJ1yX39QK73HDekAeLvjYUSUbChSOeb YjHqeygEPilV8KE39JZEGekEaGEnwR4IaZxJlkNkTQocn2jsmjAZVPzO/x6b81O2zjFx 9nDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:subject:from; bh=sf5xiWMLH6yrahkmqzkUjL0nc86L0NvxA/q4iIiAZEg=; b=XY+Wc3tXeKI6EEkqlHgjcoLeiaFEPnuG3tgDziV7vcmpCi5rAUvMlJE7SI7q51Cbbx yK36K++m8sovYvD0G3k+43RVAnYNNJcPw4OcSSyMrcCWz26JRSvRiQ2XDuu3BblXrL2Y 4O+6ODK20QzCxRJvSsbl++zeduF/VMXPA5D+mBYk/zAgxca2DwdgPyc8SCWv9S5XB02h nfow201wHeQHm4rOm/m7UeFHDxWYc4ntIn8NvUIcJoiyviiDjk8Rq3vXRQ5w9eQPnMjF 9NkTl40k5D1lzgA66YSm+y+tZPVue2gyBbgojTW41owGTkwvh4UhGH2jGbcwwWTeEu2T ZKmg== 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 d202si20033283lfe.126.2018.11.05.03.17.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 03:17:07 -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 1gJcsQ-0007QG-0v; Mon, 05 Nov 2018 14:17:02 +0300 From: Vasily Averin Subject: [PATCH v2] 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 References: <20181105061016.GA4502@intel.com> Message-ID: Date: Mon, 5 Nov 2018 14:17:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181105061016.GA4502@intel.com> 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") changed 'avail_lists' field of 'struct swap_info_struct' to an array. In popular linux distros it increased size of swap_info_struct up to 40 Kbytes and now swap_info_struct allocation requires order-4 page. Switch to kvzmalloc allows to avoid unexpected allocation failures. Acked-by: Aaron Lu Signed-off-by: Vasily Averin Acked-by: Michal Hocko --- 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()