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;