Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6525843rwb; Mon, 5 Dec 2022 13:43:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Z/iaib57hMsj9w22Bxv8sBNMQHE/2InByDT4BBsWpbHtTzW/BPOdygynMQk7dssPXJ7NL X-Received: by 2002:a17:907:3f8a:b0:7bf:4ae6:c36 with SMTP id hr10-20020a1709073f8a00b007bf4ae60c36mr33815176ejc.674.1670276620174; Mon, 05 Dec 2022 13:43:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670276620; cv=none; d=google.com; s=arc-20160816; b=q61SUTGygUtgR9nYdthwl6NYv62cp/b4VAtwcRQc9O0FiT4WqX6BZh/u/2nbKaeUkl GmLxzURWF5BVPbtg08A4/elhy3iNdTdgziRpBa7+PZZ3ZGYGp4bk87SgvFynJtyP4Xnx 5FltMNY2nQ9SmSBnu1iklR7yTALomPDc2ULy+iRYg0rNc4FnqthTtmBC52aCSiD9NrSX h2FVlKhJjnDAD9uc/q0OcDlQZfyPyeU86riCuOihe/kfVljD4MpbEeU8/VI+1IVkVCA9 vn94qVw6VU9smkl6GT/1nyr+M7lvN++5oPwvgAf3JP8/fLUE8kbJgmhw1gQu4k4o231N a8AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=BdSZyxqxqayjIvTw5z79wm5UdFJAtWErux7M6jHSUN4=; b=uyB4t8zbzePstGOdWvJrcLD/UvmKO9WXlfWjnuOSci83BJjOj4sYDxRtnGdiQ/S7oA DlkJXtDJ0maJXB2drKSuuKLn4r8pSd0knxrLYuCCJjoSNXjUTe405Q8p6rFuUewyZ+Td yd1XRbNriFx8QUPhtZuELSjdvyXCDCxGjeWTSZcNfCrupKmO74lStMMVNaKLiJoQSf65 76ImH+6Dt9w5xSqAYuR4dPPVuyH9dh0/EQuoSeVW3915EpX5iLuEQK8yir1hRKiRDmD6 1idmTGXxEjL+DWYue9MkDCzW6m4Xsul3KCO5tIHhEJVAwTuY2fQPH6goLT+61OgUdDVt Tv4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=AbQoFTmR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs18-20020a170906dc9200b00780837381d8si12216901ejc.591.2022.12.05.13.43.20; Mon, 05 Dec 2022 13:43:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=AbQoFTmR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233681AbiLEVFG (ORCPT + 80 others); Mon, 5 Dec 2022 16:05:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232470AbiLEVEc (ORCPT ); Mon, 5 Dec 2022 16:04:32 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A5072B191 for ; Mon, 5 Dec 2022 13:04:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C483261405 for ; Mon, 5 Dec 2022 21:04:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED3C2C433C1; Mon, 5 Dec 2022 21:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1670274240; bh=ZBUbOusq+sm0P5pmZB0m0ci+m3HFcOugwkBsLM2PR5Q=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AbQoFTmRgLa+Lw57I/LL4SEMpmqg3FDZ1M7SQgVL2DDh/3hBNeuSWcf+7L2HL8kUf xb8bnASaAmnMSGIP58Ti6mu11cKV2jtrhYJzgdvBiQ5Hw9Y0vpvBepZ+oSOfbCie82 R1EbPOfzdBXhbcjDIDMOgf3Bp+IWRk2nhSHuXeV8= Date: Mon, 5 Dec 2022 13:03:59 -0800 From: Andrew Morton To: Kefeng Wang Cc: , , Subject: Re: [PATCH] mm: add cond_resched() in swapin_walk_pmd_entry() Message-Id: <20221205130359.2c81c5df0fb777cf55495a02@linux-foundation.org> In-Reply-To: <20221205140327.72304-1-wangkefeng.wang@huawei.com> References: <20221205140327.72304-1-wangkefeng.wang@huawei.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 5 Dec 2022 22:03:27 +0800 Kefeng Wang wrote: > When handle MADV_WILLNEED in madvise(), the soflockup may be occurred > in swapin_walk_pmd_entry() if swapin lots of memory on slow device, > add a cond_resched() into it to avoid the possible softlockup. > > ... > > --- a/mm/madvise.c > +++ b/mm/madvise.c > @@ -226,6 +226,7 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start, > put_page(page); > } > swap_read_unplug(splug); > + cond_resched(); > > return 0; > } I wonder if this would be better in walk_pmd_range(), to address other very large walk attempts.