Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp451551imm; Fri, 29 Jun 2018 00:13:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJm+Ag174HvqRbuyyt0c75J7LAaKnqr9r7Mogc/gb6mgCzESnp1+TsOQv4UpYpazWLetGkR X-Received: by 2002:a63:7f44:: with SMTP id p4-v6mr11638046pgn.416.1530256416252; Fri, 29 Jun 2018 00:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530256416; cv=none; d=google.com; s=arc-20160816; b=k649PmzDgba4/EPAr9T0bNUo2kwPyfStldNjXAKVJs6abIMzZ0ilIFBllEh+y0hsNv ZL3hUv5fU0eVHUugQrPVl+7MoFKFleXhTnKEbpgn1QM4q7YfBrdsoysRqFDyKXAqqRhs zjPOiMgxJkoKXjv9SwqHNegxqeLUiQrOUWdikC+YU8p7ojPMZPHEwQsKvItvXw51sbKi tDVAdAX45MNCIYAn9hJm7I1Eznw25XiGk5Nrregq85oTUmTbcnrgwDbkQ2iKA+qZ6yAj AfyyvCGkP/qijiMI0O/ueXMeA2ZjOH0Nj534SAChpwKmW+i8KlV0pb+/+7ZNHFjCBX3o SN5g== 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:dkim-signature:arc-authentication-results; bh=ebZ2v2c6aypxo5GBpQA28oz8ZOr6I8YtAVamOmEXT30=; b=OA511PqsDnpqd+WxqOoDBZ2NRMEBpCXyI25beKJcYrVxuU76sBFKYCcBkkm8y2Wf1q Jtv6Nr532m3MkO1wxS4risjRTQ0DcE30itaJLokBd7syU5YjOm51SlVM4dCYYAwf21Q3 M6OG7RT9V1PYl+/FnrD2Of1jLsw0lq+p+uCRmV+/a9km91NXY4ZSkqOd+KsIcARfkrjZ vWjGZYj6TkZANdRIltl3yhCuIxMLlkqJSIj71di7+2qfo9RfArWDRb6mUhKYlnFIaF/q Gr+z0kTuv9EnNvYvEO+dkDfOjX5HYKAKh0CuXpDz8NC0dMUE3CsKYKDjnPXX+bo1B2O7 9QnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=dOZME6Nd; 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 92-v6si8481499plw.102.2018.06.29.00.13.21; Fri, 29 Jun 2018 00:13:36 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=dOZME6Nd; 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 S933871AbeF2GVo (ORCPT + 99 others); Fri, 29 Jun 2018 02:21:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:56394 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933673AbeF2GV3 (ORCPT ); Fri, 29 Jun 2018 02:21:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ebZ2v2c6aypxo5GBpQA28oz8ZOr6I8YtAVamOmEXT30=; b=dOZME6NdhtgYROZohXiHRELuI 7K2TNXnEZAFU9c+6OhreuewXWXBUqJVjr21yDuLQptsP4hO06XjOjvvZ0BdOoosVeAsTGsZYDpW0R VHHqsa1LtIueUD7slhYJFK0UMLCL+6a7o2AY5zumOMymL2VEjXTK4vHOVF5FzGXL3L4jd3pg940QI ssFwo4ikthjp8OZq555l1pYnYoZpYXL9/CHvQ5i5Ki1Nolg1TW8HxEeK0QlEM1mQ2Ehfl5mu5ZHBS Pl7oUQ+DqdcnWgbdGHwuo0PXLIL1YY/V6RkSE8sfd/YMN5/kmdZQqxQeHSIP2olYwBl5Fjqc7ch+w p+xK1UGqw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYmmc-0004si-Mz; Fri, 29 Jun 2018 06:21:26 +0000 Date: Thu, 28 Jun 2018 23:21:26 -0700 From: Matthew Wilcox To: "Huang, Ying" Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Andrea Arcangeli , Michal Hocko , Johannes Weiner , Shaohua Li , Hugh Dickins , Minchan Kim , Rik van Riel , Dave Hansen , Naoya Horiguchi , Zi Yan , Daniel Jordan Subject: Re: [PATCH -mm -v4 08/21] mm, THP, swap: Support to read a huge swap cluster for swapin a THP Message-ID: <20180629062126.GJ7646@bombadil.infradead.org> References: <20180622035151.6676-1-ying.huang@intel.com> <20180622035151.6676-9-ying.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180622035151.6676-9-ying.huang@intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 22, 2018 at 11:51:38AM +0800, Huang, Ying wrote: > +++ b/mm/swap_state.c > @@ -426,33 +447,37 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, > /* > * call radix_tree_preload() while we can wait. > */ > - err = radix_tree_maybe_preload(gfp_mask & GFP_KERNEL); > + err = radix_tree_maybe_preload_order(gfp_mask & GFP_KERNEL, > + compound_order(new_page)); > if (err) > break; There's no more preloading in the XArray world, so this can just be dropped. > /* > * Swap entry may have been freed since our caller observed it. > */ > + err = swapcache_prepare(hentry, huge_cluster); > + if (err) { > radix_tree_preload_end(); > - break; > + if (err == -EEXIST) { > + /* > + * We might race against get_swap_page() and > + * stumble across a SWAP_HAS_CACHE swap_map > + * entry whose page has not been brought into > + * the swapcache yet. > + */ > + cond_resched(); > + continue; > + } else if (err == -ENOTDIR) { > + /* huge swap cluster is split under us */ > + continue; > + } else /* swp entry is obsolete ? */ > + break; I'm not entirely happy about -ENOTDIR being overloaded to mean this. Maybe we can return a new enum rather than an errno? Also, I'm not sure that a true/false parameter is the right approach for "is this a huge page". I think we'll have usecases for swap entries which are both larger and smaller than PMD_SIZE. I was hoping to encode the swap entry size into the entry; we only need one extra bit to do that (no matter the size of the entry). I detailed the encoding scheme here: https://plus.google.com/117536210417097546339/posts/hvctn17WUZu (let me know if that doesn't work for you; I'm not very experienced with this G+ thing)