From patchwork Tue Dec 7 03:22:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xf2017140389@gmail.com X-Patchwork-Id: 12661005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBBD1C433F5 for ; Tue, 7 Dec 2021 03:22:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BB296B0082; Mon, 6 Dec 2021 22:22:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 36BD66B0085; Mon, 6 Dec 2021 22:22:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 232136B0088; Mon, 6 Dec 2021 22:22:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id 12E1D6B0082 for ; Mon, 6 Dec 2021 22:22:47 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D2A441813F3E7 for ; Tue, 7 Dec 2021 03:22:36 +0000 (UTC) X-FDA: 78889550712.27.9A077DF Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf20.hostedemail.com (Postfix) with ESMTP id 89168D0000A7 for ; Tue, 7 Dec 2021 03:22:36 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id fv9-20020a17090b0e8900b001a6a5ab1392so1498819pjb.1 for ; Mon, 06 Dec 2021 19:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=IDve8oEFAh3tm09aSKqqbG9jITENxqwhDiI+qaAmf2g=; b=f96WhxszXDg3XCQzRjBKhVEkoLn8amlNkO4xug1L9k/5SbcC2HgTGw7McJwH58DJAg jIW5pkNktzgJXHc1lxGyi+U4DA0YU6TbBpt/QZqFf+RysaxUrGxH0AJ3XMzD9qhv5Zqy /GpFKmXBUX7kNjzGFCuS12yNF+HalvKvMTKpiRGzSLK5s6zmWiKJtlgMg4XgGB8QaNfB Frg/rcHoVswQtgvCdwqz9PXg7Etup0uHLXSeIPMrfbcYOgpj2NhlWI/1/bEVtgBfWnaV O5pXmEIXCpXfPSY8C1zYrKh2Z3oPTb9LucFG/PPNWus5oTXaVDk0khCj5EmAAvmRL3Gz TWrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IDve8oEFAh3tm09aSKqqbG9jITENxqwhDiI+qaAmf2g=; b=P4Di56NTFtSqJNSjhfDB0NwCw0zhGRVb7LO0yCdXM6SkHp8ayKH32zZp3tvVZ++oW3 T59lEaN0xwiMGNpwtkf5U+HXzk9xBzFOGtmHk0yTwt8rcf03kbPRhxYfAw1iw66mn6Dj /zlXhmdKabcwGQj+/XygGeo7nXW4852jGyuoesePFBdluOCbLFkAgLj9uKGQOROzaf/H RVElk1Xn5DoIlZXA9mQ4nJlEL8jUIeyVvE6kNo1ML+mEVq+a0YrBUfo94I7XJYHbxR0U KCMuYNdd0er7kwEAXP7SrMMjWY78M/RzKyD6yokzc+LPgcXm5BzpfIYAC2ng1DLxaJwS uIFA== X-Gm-Message-State: AOAM530uu9Xg6VHfevNHXxRE7lueFaq6HDDz19gBH+ExeA8s0AdCZWGU dxR2nuUG/fKa2y+wpvT+26w= X-Google-Smtp-Source: ABdhPJxRwjbFyo302IU3D34soi4k1UchQ3L/ZcosJRvIwCAo8xh137yRc6FRdvHhnExWhNSW+SSAvQ== X-Received: by 2002:a17:90a:17ef:: with SMTP id q102mr3375708pja.116.1638847355529; Mon, 06 Dec 2021 19:22:35 -0800 (PST) Received: from monster.mioffice.cn ([2408:8607:1b00:7:82e8:2cff:fed2:80d9]) by smtp.gmail.com with ESMTPSA id o124sm13707624pfb.177.2021.12.06.19.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 19:22:34 -0800 (PST) From: xf2017140389@gmail.com X-Google-Original-From: xiaofeng5@xiaomi.com To: akpm@linux-foundation.org, christian@brauner.io Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, zhangcang@xiaomi.com, wangju@xiaomi.com, surenb@google.com, fangzhirong@xiaomi.com, xiaofeng Subject: [PATCH] mm/madvise: break reclaim when lock race Date: Tue, 7 Dec 2021 11:22:02 +0800 Message-Id: <20211207032202.6022-1-xiaofeng5@xiaomi.com> X-Mailer: git-send-email 2.17.1 X-Stat-Signature: z36n1gsx1xrfugohc55tbq4meay4qaqb Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=f96Whxsz; spf=pass (imf20.hostedemail.com: domain of xf2017140389@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=xf2017140389@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 89168D0000A7 X-HE-Tag: 1638847356-431289 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: xiaofeng When the process_madvise() system call is being used, it takes mmap_lock and blocks the application from allocating memory, leading to unreasonable delays. This patchset aims to fix it. Signed-off-by: xiaofeng --- mm/madvise.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/madvise.c b/mm/madvise.c index 8c927202bbe6..8f1e325873e0 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -322,6 +322,9 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, if (fatal_signal_pending(current)) return -EINTR; + if (mmap_lock_is_contended(mm)) + return -EINTR; + #ifdef CONFIG_TRANSPARENT_HUGEPAGE if (pmd_trans_huge(*pmd)) { pmd_t orig_pmd;