From patchwork Fri Jul 1 20:08:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12903724 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 ED199C43334 for ; Fri, 1 Jul 2022 20:08:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 174146B0071; Fri, 1 Jul 2022 16:08:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D73B6B0073; Fri, 1 Jul 2022 16:08:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB84C6B0074; Fri, 1 Jul 2022 16:08:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DB1B46B0071 for ; Fri, 1 Jul 2022 16:08:29 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B3E4433CA3 for ; Fri, 1 Jul 2022 20:08:29 +0000 (UTC) X-FDA: 79639618338.25.EA7A9FA Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf18.hostedemail.com (Postfix) with ESMTP id 372941C0045 for ; Fri, 1 Jul 2022 20:08:29 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id 73-20020a17090a0fcf00b001eaee69f600so3748380pjz.1 for ; Fri, 01 Jul 2022 13:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:content-language:from :subject:to:cc:content-transfer-encoding; bh=7feO+GwmVWhGO6QGyCvsxclP8u2/be5/IE4Dt53HZC0=; b=D+S95WkSOe7BeBEsq4dxURIDPQhKwNta6iK33RWz+mArkWyQ925qFfLKwWhnJg3YQC rjKHT+d2bsF/2uOKBuIkVSzc0w55DrsIny3kosKHQPvjTpN/J11Ah8icqLfFBxBwx4ja Wh3bYtylfESNwa9C3MdDssvinN7a89sFhdEBPiPitRgy2TjwHQoW7+2JjpCGeVfgv0/U UhThhDunDo+957EfV0RKi0ONIZBFJTecs3B7ySxRVpucJvzd5foVXSHElxcrTILMzfYO ebmXB5/3sXDKPkH+kElUE0riXw7QtY2ihIPJYAy1JgayR++XvapfRjv/1ZghZf7V8/j3 y+yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:from:subject:to:cc:content-transfer-encoding; bh=7feO+GwmVWhGO6QGyCvsxclP8u2/be5/IE4Dt53HZC0=; b=tvsgIFfdaKvgrBrwXRmXyWVnYuB96U80BqS4CnKxtDmjGZjAZDJj2LGmMYBrOLTDgp RAeSbKv6UQMppMv4XqbOGmmak7MbNWNSbAAYk4UcPf82RPXOtDQbGyhp85Ms7DLopPM5 21sFDZJf65syOrbz0DTRMSLdn0Q/xe8mvnf1K+dITxQvGG237sYe81EsrePe819+sK52 i/By/BR+Rj5IqCQhf/qay58eOxmUnmNV5Nz4hSNPuiArfis3NJtsnfLTc2M49/uiAnSw xoowyT6bMtHh4/lTJYAcjyvcLqGsGzk+q47EF6FZlRooRCacRF+q+nbpBnkNTh9fgzh+ 41qQ== X-Gm-Message-State: AJIora+r4UCaEBkfkAt+O6bOi9PqcrkOKp10eXTTpHcTMlVZySsv4vpd AuQqlzKdndHUPe5hdIsbGFypzg== X-Google-Smtp-Source: AGRyM1uPejuC08aYW9Oh8uEZg7T6er/9ms7hkiw4b4BPx0sUmv1lRMumCNTYyO08EW1+hsRpukxrGg== X-Received: by 2002:a17:90b:1e4f:b0:1ed:4837:5f94 with SMTP id pi15-20020a17090b1e4f00b001ed48375f94mr20167183pjb.68.1656706108149; Fri, 01 Jul 2022 13:08:28 -0700 (PDT) Received: from [192.168.1.100] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001663cf001besm1059720plg.174.2022.07.01.13.08.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Jul 2022 13:08:27 -0700 (PDT) Message-ID: Date: Fri, 1 Jul 2022 14:08:26 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Content-Language: en-US From: Jens Axboe Subject: [PATCH] mm: honor FGP_NOWAIT for page cache page allocation To: Matthew Wilcox , linux-mm@kvack.org Cc: Stefan Roesch ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656706109; a=rsa-sha256; cv=none; b=F6eqOCaGZ57+lWEif6eDjn3HnwTMnKnIwpPI9RhxvYjOlw1hh0yztLcS8Gp86PwIWZi58p EG/wSy2fEUujNUsPC+rtuBZUBHGnz1lkMiA21J+W5AA9oIwGWw37jeYkQZaIyWBcw3JGzP l0hrSnOA047uiOFjfaHGUa0H9Ah36Ds= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=D+S95WkS; dmarc=none; spf=pass (imf18.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.54 as permitted sender) smtp.mailfrom=axboe@kernel.dk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656706109; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=7feO+GwmVWhGO6QGyCvsxclP8u2/be5/IE4Dt53HZC0=; b=RZPdsNnmJf9FyDlhN450veKlfd5d2Lp4fqjZ03ANAqqQVmUzDFmClNGF/c/65IFKAgzcbB zIcxU0/4q+1qEVn5YfwS9nkItRVhUK7yeVElmP4QfU2A3NQ+MuUWUeS+PK6TtZWtx8Km0w F36ClJZe2N6mXCd64DnO3J3oGe4MTNs= X-Rspamd-Queue-Id: 372941C0045 X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=D+S95WkS; dmarc=none; spf=pass (imf18.hostedemail.com: domain of axboe@kernel.dk designates 209.85.216.54 as permitted sender) smtp.mailfrom=axboe@kernel.dk X-Rspamd-Server: rspam02 X-Stat-Signature: rw8mmmujowewi8g7j1qqdrzbkoh8tmd6 X-HE-Tag: 1656706109-176318 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: If we're creating a page cache page with FGP_CREAT but FGP_NOWAIT is set, we should dial back the gfp flags to avoid frivolous blocking which is trivial to hit in low memory conditions: [ 10.117661] __schedule+0x8c/0x550 [ 10.118305] schedule+0x58/0xa0 [ 10.118897] schedule_timeout+0x30/0xdc [ 10.119610] __wait_for_common+0x88/0x114 [ 10.120348] wait_for_completion+0x1c/0x24 [ 10.121103] __flush_work.isra.0+0x16c/0x19c [ 10.121896] flush_work+0xc/0x14 [ 10.122496] __drain_all_pages+0x144/0x218 [ 10.123267] drain_all_pages+0x10/0x18 [ 10.123941] __alloc_pages+0x464/0x9e4 [ 10.124633] __folio_alloc+0x18/0x3c [ 10.125294] __filemap_get_folio+0x17c/0x204 [ 10.126084] iomap_write_begin+0xf8/0x428 [ 10.126829] iomap_file_buffered_write+0x144/0x24c [ 10.127710] xfs_file_buffered_write+0xe8/0x248 [ 10.128553] xfs_file_write_iter+0xa8/0x120 [ 10.129324] io_write+0x16c/0x38c [ 10.129940] io_issue_sqe+0x70/0x1cc [ 10.130617] io_queue_sqe+0x18/0xfc [ 10.131277] io_submit_sqes+0x5d4/0x600 [ 10.131946] __arm64_sys_io_uring_enter+0x224/0x600 [ 10.132752] invoke_syscall.constprop.0+0x70/0xc0 [ 10.133616] do_el0_svc+0xd0/0x118 [ 10.134238] el0_svc+0x78/0xa0 Clear IO, FS, and reclaim flags and mark the allocation as nowarn, as FGP_NOWAIT are expected to be able to handle -EAGAIN failures and retry from a suitable context without NOWAIT set. Signed-off-by: Jens Axboe --- mm/filemap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index ffdfbc8b0e3c..9b747d3247c6 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1988,6 +1988,10 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, gfp |= __GFP_WRITE; if (fgp_flags & FGP_NOFS) gfp &= ~__GFP_FS; + if (fgp_flags & FGP_NOWAIT) { + gfp &= ~GFP_KERNEL; + gfp |= __GFP_NOWARN; + } folio = filemap_alloc_folio(gfp, 0); if (!folio)