From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 545FBC433E0 for ; Thu, 14 Jan 2021 18:04:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CF31323A34 for ; Thu, 14 Jan 2021 18:04:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF31323A34 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3E3A38D0101; Thu, 14 Jan 2021 13:04:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 392E08D00F0; Thu, 14 Jan 2021 13:04:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2825F8D0101; Thu, 14 Jan 2021 13:04:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0254.hostedemail.com [216.40.44.254]) by kanga.kvack.org (Postfix) with ESMTP id 0E95F8D00F0 for ; Thu, 14 Jan 2021 13:04:13 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C513E824556B for ; Thu, 14 Jan 2021 18:04:12 +0000 (UTC) X-FDA: 77705154744.15.dirt62_2512b0e27528 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 89569180339A3 for ; Thu, 14 Jan 2021 18:04:12 +0000 (UTC) X-HE-Tag: dirt62_2512b0e27528 X-Filterd-Recvd-Size: 6493 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 14 Jan 2021 18:04:11 +0000 (UTC) Received: by mail-pf1-f174.google.com with SMTP id h186so3826519pfe.0 for ; Thu, 14 Jan 2021 10:04:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8odJ5Ie7ToqG86xlcAIvMtTg4Qjk76VUQrxBhxSFP9w=; b=KqQCOKjiLJiLiQqwtMYuTPhPw5CF0QxgEHNynmvelI5fjabtoMBGY3djLOvXx5It0t qaPYxThjlfWhP5EGs7o4xswci/ZIluAll1SNOkKP9pGvLSn1YPnpngCI80o4Ds1yVooa vIiZRQIojuqqDnI+/rXRiNk697Ae+YBgYbcWlfuJfYF9U9UlX04F/P82YOG7SvcMD9ne PPsDUEv6ogXeSKomJ1WHDMchwdg63akHJpmzlxq2vw/N/rJXmy+v2FYJLEMpuVF/pPWS IZ/xz9b5PA0a5yC+5yVqFVzhes6gq+Xoh/eJ57A1Z7zXo65wLwLveEdBL4YwClXHOKlg BrIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=8odJ5Ie7ToqG86xlcAIvMtTg4Qjk76VUQrxBhxSFP9w=; b=tv/ab8T1HRMCYlqzsrUu18m/TwqTdNwR9b9vHhB43UQPGsFPtMxSoFYxH7P2/Br50d kujD3ZkpPZEqSVw6yl45fMj7sWu7PvdsWKgPyGG/TwaN7GNRtZ1Pog9cZj3ecnRATpeA OhKvinPiKQ1wP4Ber73cLGAGgNc4EJPN1fFp+ivVG2Kmtkv4Crk4CeEY3DTq0pCQlklh z75LQvRja4NlqpG2dtFB7NC7m7ejvUS82/ujAhUu8JWOqcN637FFTeq/KAGiTTi8qw6F yFY6dKFHcID9rDCx/jxGh+5/DtJHaK/YOTbGHx+QignNVqkqCIZs0u5M3Z/KMtgvP8gu QGwQ== X-Gm-Message-State: AOAM532R8cUiUSV1STAfWf6dvmPg+aUrH+grg9zQQxrFtR9m3eLBDWHe GdKMFqs/Dg8KEkcBwE/GwwU= X-Google-Smtp-Source: ABdhPJwoNeFU6lwLeDKNvAWYiFtl2UOGPDfDpM4zGt/q0XPR8pdVQPV+E8PEIiPTuGm7rCuI3/aJQA== X-Received: by 2002:a63:4f64:: with SMTP id p36mr8531861pgl.374.1610647451015; Thu, 14 Jan 2021 10:04:11 -0800 (PST) Received: from google.com ([2620:15c:211:201:7220:84ff:fe09:5e58]) by smtp.gmail.com with ESMTPSA id n15sm6074557pgl.31.2021.01.14.10.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 10:04:09 -0800 (PST) Date: Thu, 14 Jan 2021 10:04:07 -0800 From: Minchan Kim To: David Hildenbrand , mhocko@suse.com Cc: Andrew Morton , linux-mm , LKML , hyesoo.yu@samsung.com, mhocko@suse.com, surenb@google.com, pullip.cho@samsung.com, joaodias@google.com, hridya@google.com, john.stultz@linaro.org, sumit.semwal@linaro.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, hch@infradead.org, robh+dt@kernel.org, linaro-mm-sig@lists.linaro.org Subject: Re: [PATCH v3 2/4] mm: failfast mode with __GFP_NORETRY in alloc_contig_range Message-ID: References: <20210113012143.1201105-1-minchan@kernel.org> <20210113012143.1201105-3-minchan@kernel.org> <723e935f-3aa4-2c55-8d69-fcaf71f4eb4c@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <723e935f-3aa4-2c55-8d69-fcaf71f4eb4c@redhat.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: On Wed, Jan 13, 2021 at 09:39:26AM +0100, David Hildenbrand wrote: > On 13.01.21 02:21, Minchan Kim wrote: > > Contiguous memory allocation can be stalled due to waiting > > on page writeback and/or page lock which causes unpredictable > > delay. It's a unavoidable cost for the requestor to get *big* > > contiguous memory but it's expensive for *small* contiguous > > memory(e.g., order-4) because caller could retry the request > > in diffrent range where would have easy migratable pages > > without stalling. > > s/diffrent/different/ > > > > > This patch introduce __GFP_NORETRY as compaction gfp_mask in > > alloc_contig_range so it will fail fast without blocking > > when it encounters pages needed waitting. > > s/waitting/waiting/ Fxed both. Thanks. Let me resend once I get some review. Michal, I appreciate if you could give an review before next revision. Thanks! > > > > > Signed-off-by: Minchan Kim > > --- > > mm/page_alloc.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 5b3923db9158..ff41ceb4db51 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -8489,12 +8489,16 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, > > unsigned int nr_reclaimed; > > unsigned long pfn = start; > > unsigned int tries = 0; > > + unsigned int max_tries = 5; > > int ret = 0; > > struct migration_target_control mtc = { > > .nid = zone_to_nid(cc->zone), > > .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > > }; > > > > + if (cc->alloc_contig && cc->mode == MIGRATE_ASYNC) > > + max_tries = 1; > > + > > migrate_prep(); > > > > while (pfn < end || !list_empty(&cc->migratepages)) { > > @@ -8511,7 +8515,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, > > break; > > } > > tries = 0; > > - } else if (++tries == 5) { > > + } else if (++tries == max_tries) { > > ret = ret < 0 ? ret : -EBUSY; > > break; > > } > > @@ -8562,7 +8566,7 @@ int alloc_contig_range(unsigned long start, unsigned long end, > > .nr_migratepages = 0, > > .order = -1, > > .zone = page_zone(pfn_to_page(start)), > > - .mode = MIGRATE_SYNC, > > + .mode = gfp_mask & __GFP_NORETRY ? MIGRATE_ASYNC : MIGRATE_SYNC, > > .ignore_skip_hint = true, > > .no_set_skip_hint = true, > > .gfp_mask = current_gfp_context(gfp_mask), > > > > I'm fine with using gfp flags (e.g., __GFP_NORETRY) as long as they > don't enable other implicit behavior (e.g., move draining X to the > caller) that's hard to get from the flag name. > > IMHO, if we ever want to move draining to the caller, or change the > behavior of alloc_contig_range() in different ways (e.g., disable PCP), > we won't get around introducing a separate set of flags for > alloc_contig_range(). > > Let's see what Michal thinks. Thanks! > > -- > Thanks, > > David / dhildenb >