Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp185671imu; Sun, 4 Nov 2018 22:11:21 -0800 (PST) X-Google-Smtp-Source: AJdET5dBCbYF2Q7glHGyMj6P+eI+oluZBUgldLx0bmD0gF1T3qSqdHQvTTWRnXtEHRLXm8FqHD0Y X-Received: by 2002:a17:902:2cc1:: with SMTP id n59-v6mr20274769plb.144.1541398281249; Sun, 04 Nov 2018 22:11:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541398281; cv=none; d=google.com; s=arc-20160816; b=qIH1BKfxy+ruJ5x1jJXAierid4ErfpYG5A1DaH+/1398OhKBxX4KN34NwgfJGqGCTo 8iwZTEYTQiOw6tJBeqTNrwRzEcxvmzLJOay5j4gayblTWQn0hID9Baus5wXNOqAw5kkV 8RW88yLB9SBh8UDZK3QUmddIZAQW1G1J4xW+vhS3MQ/8UIiLQ7o5uSUz+xBFw/wcMx5j aR9PJKAw4FVs1YxOdnZdwHvL4L6wZw/Iw+7vZnIx8WkgmT4qBMAnNkm7WTXi/MkcXtSv 6lDyjztNdlONl/b4uFjlDc1FBFplFTuRXCW+npKSD6J3WC/xABJkrZeAkokmiONqPFak 7nXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ZkI7ma3cUJT+9cHPn7gUMxVir9TAV2pNfSPbnjr2U1A=; b=0IEA3EmYZwwfph+Yw00q13ryA9ei41jN3FYMXaxdxyKhdg8xzwS4++AZ+aDoepF5X9 82UXnF0WfZ149MlCX+l2wj997zQIsIXOW1sqZE2WlPYy3v7XgblsM4OKx8hqnmyPbZCZ 3EvcTHRgs2aFkJXmiaWwJiiMZVGQ1tEKRV5ERedeXNUy8ujYlHfabhjjCze06arycFU+ jeQ8rxBzGd/rVRVGv8VB6aGL9aXebQ6JWBgAffcxMfLqdH5F7yDxMiBV1oiHG+kWZ79/ fO5RuwlHNEg5/4K/HqZUmcItqmF6ordReP4mMDxy5vmxMkbLtbc5i8AxKlK6VxZcDZZg 3O9Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3-v6si43025345pgr.325.2018.11.04.22.11.06; Sun, 04 Nov 2018 22:11:21 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729319AbeKEP2T (ORCPT + 99 others); Mon, 5 Nov 2018 10:28:19 -0500 Received: from mga01.intel.com ([192.55.52.88]:21547 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728625AbeKEP2T (ORCPT ); Mon, 5 Nov 2018 10:28:19 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Nov 2018 22:10:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,466,1534834800"; d="scan'208";a="247016571" Received: from aaronlu.sh.intel.com (HELO intel.com) ([10.239.159.44]) by orsmga004.jf.intel.com with ESMTP; 04 Nov 2018 22:10:16 -0800 Date: Mon, 5 Nov 2018 14:10:16 +0800 From: Aaron Lu To: Vasily Averin Cc: "Huang, Ying" , linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm: use kvzalloc for swap_info_struct allocation Message-ID: <20181105061016.GA4502@intel.com> References: <37b60523-d085-71e9-fef9-80b90bfcef18@virtuozzo.com> <87wopsbb5v.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 05, 2018 at 07:59:13AM +0300, Vasily Averin wrote: > > > On 11/5/18 3:50 AM, Huang, Ying wrote: > > Vasily Averin writes: > > > >> 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. > > > > Why swap_info_struct could be so large? Because MAX_NUMNODES could be > > thousands so that 'avail_lists' field could be tens KB? If so, I think > > it's fair to use kvzalloc(). Can you add one line comment? Because > > struct swap_info_struct is quite small in default configuration. > > I was incorrect not 44Kb but 40kb should be here. > We have found CONFIG_NODES_SHIFT=10 in new RHEL7 update 6 kernel, > default ubuntu kernels have the same setting too. > > crash> struct swap_info_struct -o > struct swap_info_struct { > [0] unsigned long flags; > [8] short prio; > ... > [140] spinlock_t lock; > [144] struct plist_node list; > [184] struct plist_node avail_lists[1024]; <<<< here So every 'struct plist_node' takes 40 bytes and 1024 of them take a total of 40960 bytes, which is 10 pages and need an order-4 page to host them. It looks a little too much, especially consider most of the space will left be unused since most systems have nodes <= 4. I didn't realize this problem when developing this patch, thanks for pointing this out. I think using kvzalloc() as is done by your patch is better here as it can avoid possible failure of swapon. Acked-by: Aaron Lu BTW, for systems with few swap devices this may not be a big deal, but according to your description, your workload will create a lot of swap devices and each of them will likely cause an order-4 unmovable pages allocated(when kvzalloc() doesn't fallback). I was thinking maybe we should convert avail_lists to a pointer in swap_info_struct and use vzalloc() for it. Thanks, Aaron > [41144] struct swap_cluster_info *cluster_info; > [41152] struct swap_cluster_list free_clusters; > ... > [41224] spinlock_t cont_lock; > } > SIZE: 41232 > > struct swap_info_struct { > ... > RH_KABI_EXTEND(struct plist_node avail_lists[MAX_NUMNODES]) /* entry in swap_avail_head */ > ... > } > > #define MAX_NUMNODES (1 << NODES_SHIFT) > > #ifdef CONFIG_NODES_SHIFT > #define NODES_SHIFT CONFIG_NODES_SHIFT > #else > #define NODES_SHIFT 0 > #endif > > /boot/config-4.15.0-38-generic:CONFIG_NODES_SHIFT=10 >