From patchwork Fri Dec 21 21:40:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10741071 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 E6CC96C5 for ; Fri, 21 Dec 2018 21:46:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5E082861C for ; Fri, 21 Dec 2018 21:46:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C942A2863E; Fri, 21 Dec 2018 21:46:05 +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,UNPARSEABLE_RELAY 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 9D2E12861C for ; Fri, 21 Dec 2018 21:46:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 553308E0011; Fri, 21 Dec 2018 16:46:03 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4DA298E0001; Fri, 21 Dec 2018 16:46:03 -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 3F2328E0011; Fri, 21 Dec 2018 16:46:03 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id F252F8E0001 for ; Fri, 21 Dec 2018 16:46:02 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id n17so6099707pfk.23 for ; Fri, 21 Dec 2018 13:46:02 -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:to:cc :subject:date:message-id; bh=sffhA68lKJmEgb3oAtxA6VkFYvwWlTdKGwqptP52doc=; b=nSdKBBBm5dMXFCuE5QmO9QMJxBU0NGPFQLlIpHdDwLWU0pirO4QCi2xh7muNoJdBtY BUxbBLD4dfvoSnZZIFki38fuYM9NmBKH2vsZ4HWqrxNXm4Tl5zVrsiYd5g1s6u/518vR c+T6zkT2kTk1V0hdbvync1O8uDJ+auxeVkjFHxlcehxngdJCQjd8u3+euxhL2uW0gr4O gsxCSUP1fFbOCVy2sk3agpV5iLyeWSFKR4NXIuo1+GLDDWHlerzMtq5FVW4gDsbN57U5 O2hS58Ey6cL+S/jiYJmj1404X3qm72w0/L9b5RhAZbG0hVoWv9Idckd31LEgzMvDEetm KHbg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: AJcUukeoo3RwQ1yRKw7H3X2UDX9erktrX1a5IN3u99+ZM048B1cDYHUq 6KuxlF0gg3MMftGNIB3Tcl3mnzWG3ILIdToSIb5pIVbU8YseMzCGDJ1zxheHDJDhq/h8Qb+1H4L U2oHLhhBFOWbpUhkviVzn39b1CA8gZf7yRP4Oq1B38aP4L1oK9QFm7BuyfRGnqanbFQ== X-Received: by 2002:a65:47ca:: with SMTP id f10mr4108502pgs.166.1545428762587; Fri, 21 Dec 2018 13:46:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN6ic0fBJypbRMIVPD+ejNjYhbzxFPHHUYn6aikOJP3UEpxi1DMKPbT/OvQaG4fbsRfvfaLE X-Received: by 2002:a65:47ca:: with SMTP id f10mr4108467pgs.166.1545428761665; Fri, 21 Dec 2018 13:46:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545428761; cv=none; d=google.com; s=arc-20160816; b=SJf7ShsrWUmwfBxZTz7C6gr6LSJCfB/K03AN68zypXqwBwPmMKVLcBoMDjRr14eh4A moFo/CBjCJTPDxg1z4Oxhwnfsqa+uSzEqSlkV5S0yr69vOp2df/m4T3Iubw8veuv3BYI gIiFAVwRfFIrRge4ex0wZLzuas84a3AVLXOvZTmXp3af9H+7GdH6WCZvYPhqgKzZLsdw /4DN5ehfTXY66i1Wjzcsuq+Dgq4sRMEonnMQoCxZz97fv6NGMb9GzLXVxz6mTzdjOPsA I+jNAreukQegJikCadERTx5yKzCezq0EKRGu4IOh5qVL9gxLOXXc1H4KQrGh3EaIHKhe s6hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=sffhA68lKJmEgb3oAtxA6VkFYvwWlTdKGwqptP52doc=; b=hJZehHwstusGQtAYht0SHCfYY18Zwa+UsShTa0G+3V/zYjtGR1wk5TzuI9/2z4VSk7 z4sEuEDQfTIBNOh/3vHMGZf1Pt42bjZn/dyGlPfHpomo577C1PKCodpKECv86wYMNFSV HsVVaiZs6k7xi4XssVo40xKBUCX6krAPJwFXze0PfGVBhr7SApJcWgTp4/WpPEFdI829 6iAoTt0qcIro+EeRBlWEDrcKbFe0Wg3LJnmMYm9mhH/DfUs7JPvAUyVj9bEsjs1TRtlC QivZSpJpmjpdh0zPsSr7Ztr3K7AJzHfITKN/DUiTr8Y2KBoabBF1Swl3en6t+Mv78A1a ZVTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out4437.biz.mail.alibaba.com (out4437.biz.mail.alibaba.com. [47.88.44.37]) by mx.google.com with ESMTPS id q14si22013778pgg.433.2018.12.21.13.46.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Dec 2018 13:46:01 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) client-ip=47.88.44.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07449;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TGLFtxI_1545428421; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TGLFtxI_1545428421) by smtp.aliyun-inc.com(127.0.0.1); Sat, 22 Dec 2018 05:40:28 +0800 From: Yang Shi To: ying.huang@intel.com, tim.c.chen@intel.com, minchan@kernel.org, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v3 PATCH 1/2] mm: swap: check if swap backing device is congested or not Date: Sat, 22 Dec 2018 05:40:19 +0800 Message-Id: <1545428420-126557-1-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 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 Swap readahead would read in a few pages regardless if the underlying device is busy or not. It may incur long waiting time if the device is congested, and it may also exacerbate the congestion. Use inode_read_congested() to check if the underlying device is busy or not like what file page readahead does. Get inode from swap_info_struct. Although we can add inode information in swap_address_space (address_space->host), it may lead some unexpected side effect, i.e. it may break mapping_cap_account_dirty(). Using inode from swap_info_struct seems simple and good enough. Just does the check in vma_cluster_readahead() since swap_vma_readahead() is just used for non-rotational device which much less likely has congestion than traditional HDD. Although swap slots may be consecutive on swap partition, it still may be fragmented on swap file. This check would help to reduce excessive stall for such case. Cc: Huang Ying Cc: Tim Chen Cc: Minchan Kim Signed-off-by: Yang Shi Acked-by: Tim Chen --- v3: Move inode deference under swap device type check per Tim Chen v2: Check the swap device type per Tim Chen mm/swap_state.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/swap_state.c b/mm/swap_state.c index fd2f21e..78d500e 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -538,11 +538,18 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask, bool do_poll = true, page_allocated; struct vm_area_struct *vma = vmf->vma; unsigned long addr = vmf->address; + struct inode *inode = NULL; mask = swapin_nr_pages(offset) - 1; if (!mask) goto skip; + if (si->flags & (SWP_BLKDEV | SWP_FS)) { + inode = si->swap_file->f_mapping->host; + if (inode_read_congested(inode)) + goto skip; + } + do_poll = false; /* Read a page_cluster sized and aligned cluster around offset. */ start_offset = offset & ~mask; From patchwork Fri Dec 21 21:40:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10741073 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 223496C5 for ; Fri, 21 Dec 2018 21:47:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12A9D2861C for ; Fri, 21 Dec 2018 21:47:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 044402863E; Fri, 21 Dec 2018 21:47:02 +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,UNPARSEABLE_RELAY 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 92CF92861C for ; Fri, 21 Dec 2018 21:47:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 948AF8E0012; Fri, 21 Dec 2018 16:47:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8F87B8E0001; Fri, 21 Dec 2018 16:47:00 -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 79B9D8E0012; Fri, 21 Dec 2018 16:47:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 392578E0001 for ; Fri, 21 Dec 2018 16:47:00 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id b8so6145742pfe.10 for ; Fri, 21 Dec 2018 13:47:00 -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:to:cc :subject:date:message-id:in-reply-to:references; bh=lcjD1zBeERRxJjf2F3hugdxuZivyMNd/i0PSrUp1gXo=; b=F33vEK5RIdq1NoXfDjRoBYOEB0M1ryGRQ3wYD2Ss+VSIIf2AJK5yWiC+JqNbVjho9K EyVMzaoEXohlmH2mdgrfn4mdqlwqvOcKl0w+HFqxxnfc1vMPn86FwS6G1aHGeZZKkh3p 5JSSltPClsAz/DFAHtaS4m8BuoMizFdnZBUFar/L3JKLl+GHH+H/du3WuYr+7RB2pUkI DCMMtNo2HMTIMxWQmC++YXFkkk8MSWAT3nzUAdJIa1NiU2ui65cmQp/8nKos/ncIIUcn zjwL7N7bAgc7hjC5BtGRDWaddtcpCBsx2F+LtaTtn1yyPLFbaKpyM0UZlOS6tOuCkxkj ss3w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: AJcUukei1iBeNBgmTvjfAOduWp/EW9+PtNk3j9joThcywi/k/aDCAujO Zwmg917X1RcOIAdk54AebHWPPm0SdZhYR64k/iW2iqCuK/rbU/M+4Isq/5awRhpZH9mkz9tXSLT WQOI2a6edr6ZhO8ccFwa/z2ltMhxLANGz4pS/8UuXTuzwNBaHVrwiR5HKevQoihnhTQ== X-Received: by 2002:a63:fb4c:: with SMTP id w12mr4021509pgj.321.1545428819849; Fri, 21 Dec 2018 13:46:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN4GZ4dTQpBzTGqoVlPswdwb3+gEWKGXi4WEQLR4Dx0FkqbRjx/R6deUuhv9wyo65tkWO4a3 X-Received: by 2002:a63:fb4c:: with SMTP id w12mr4021476pgj.321.1545428818909; Fri, 21 Dec 2018 13:46:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545428818; cv=none; d=google.com; s=arc-20160816; b=CgiDM4UWVNN1rTjbDCODWUGPDZJ+4VKm1PIS78RkxttB6av6YMhDyOHxpOouKHNhx6 zPcZcl06IAHXxZAiLb3zRroeiT41IBbsV7iMPC74wVn+a2jsvbhwXsCOzL6K4gxC3CiB N56GJEC7zjxxiKA3eXXp70yYrxHccd/k1kIHTZWHCPkYbp7LmYCmwcv8eRXSeNu12BLA eV3y+k5gOaWLoIYE4/OvDA1Ujx6nqh8nJ6D7EUngDF2iVcz3GZZLkLLTVTbfBz1GYFsX RKDIXcrbpPm8hwyXGwPjl+M50qTelf4LKAse+KoQAru3u2FQP6+H2W1zoi+o+VgOQ45C cHeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=lcjD1zBeERRxJjf2F3hugdxuZivyMNd/i0PSrUp1gXo=; b=jNMenfY96fu8UhEzsPHFHZvoGoJWwrGk6t56kZZLneS3GjbEicp7Il5xBjpmcxTtuk XvEGmsxWheBKe6YSbJDGa0LeN5GH4pJgCwT93v6zlbIXXppN2E4FiaH0RMe02TunhbDk zOlSYpyld6IvvqcSKoZeAz56pTAQIwrqLQGmFMPGyijx9se5xdGo+9oJR4a11jHGm8YD BjfNXX0BFWCk1D5z2ckpYr4NedQ2pd3JgDhWS0FGsBmZz56yS0nirDfZ5rZ2DMmxygkN bj4E4DtJ5xyjyy2GnUSNJsFFVBCGPRIAWBn1NKvAx/j9vWLyUUphjmWNH36dcCGY7iPJ t3jw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out4436.biz.mail.alibaba.com (out4436.biz.mail.alibaba.com. [47.88.44.36]) by mx.google.com with ESMTPS id d23si22376637pgm.559.2018.12.21.13.46.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Dec 2018 13:46:58 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) client-ip=47.88.44.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04428;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TGLFtxI_1545428421; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TGLFtxI_1545428421) by smtp.aliyun-inc.com(127.0.0.1); Sat, 22 Dec 2018 05:40:28 +0800 From: Yang Shi To: ying.huang@intel.com, tim.c.chen@intel.com, minchan@kernel.org, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v3 PATCH 2/2] mm: swap: add comment for swap_vma_readahead Date: Sat, 22 Dec 2018 05:40:20 +0800 Message-Id: <1545428420-126557-2-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1545428420-126557-1-git-send-email-yang.shi@linux.alibaba.com> References: <1545428420-126557-1-git-send-email-yang.shi@linux.alibaba.com> 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 swap_vma_readahead()'s comment is missed, just add it. Cc: Huang Ying Cc: Tim Chen Cc: Minchan Kim Signed-off-by: Yang Shi --- mm/swap_state.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mm/swap_state.c b/mm/swap_state.c index 78d500e..dd8f698 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -698,6 +698,23 @@ static void swap_ra_info(struct vm_fault *vmf, pte_unmap(orig_pte); } +/** + * swap_vm_readahead - swap in pages in hope we need them soon + * @entry: swap entry of this memory + * @gfp_mask: memory allocation flags + * @vmf: fault information + * + * Returns the struct page for entry and addr, after queueing swapin. + * + * Primitive swap readahead code. We simply read in a few pages whoes + * virtual addresses are around the fault address in the same vma. + * + * This has been extended to use the NUMA policies from the mm triggering + * the readahead. + * + * Caller must hold down_read on the vma->vm_mm if vmf->vma is not NULL. + * + */ static struct page *swap_vma_readahead(swp_entry_t fentry, gfp_t gfp_mask, struct vm_fault *vmf) {