Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3281617lfo; Mon, 23 May 2022 00:36:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzE2qHA0DlGaEj5K0MBAegYFs3U9XHeEC7f7NjxNyaX4R4HrZKYB/tg+8VfTl2MVv7MEkT/ X-Received: by 2002:a05:6a00:1511:b0:510:30d1:e8fd with SMTP id q17-20020a056a00151100b0051030d1e8fdmr22640789pfu.37.1653291414582; Mon, 23 May 2022 00:36:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653291414; cv=none; d=google.com; s=arc-20160816; b=LPaBGB86DiyIenzZCg2PYOKEJVA7XHGtN6bdGEylXCZzD9/Yw4UoOH4tRkUpfA0xkR 3JuDvdmUW876srm0pMnPNPYlggWWYgLQ9BO3NT1ZkN2TfyTktR1pqB7JV0XdkjO7DDed 6bq5qcQgKL6gzG/11RrRLe5+0mp7w5KKiUeZg1A6oqAJdqzSLsKUhMuALBqsbApGxjzZ /gb5moUO5TKQ17zJLuLOIAnir1bXHWw469MB6i+q/FzZZpsL5vkfZ7fMUlKdzhnHr1Iw LvBPBnbGRiNwf1ooxtbcI3IFd2hDCDwvnjjoVs6PbrNPunaEvh9P+dfhS0VBlXhCf1iG GBMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=FJNM+SC0IIR+V8IbK3b8r/wd9vAA7Bdywff6gYSjtWo=; b=LnQfvEU9jcGo0G9bWV0CwutUJcWlwJEPwyLDCsHa02tS8sZrimBphJWQJv28Jbkmfk D6fbWHSDnML5A/aoS72KKAWGzpJRDWeMH37mTA3IpVioaVd9o+lHJY5VPsAaverk/Hou 4FPTG4RV0kgv0V9R7gBk7YJ5zkTpeiBJjePh81BjSDJKf99CmOLhjCXBv3fiDznrce5R FqlL6dcCDfXstcrCxs2tVp5xk9TzBqSgy6XM//ljiASYbqq2GKE1Q4/hWRuj3cCzfTy6 abpdCko7be7aelup2uGgO0UWJXCLC2CxOUka0gMCaO6jMyopjQ3a1pPNXljvW7imYiPF Po8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IAMIx2qm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e21-20020a631e15000000b003c14551f78asi9326045pge.165.2022.05.23.00.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:36:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IAMIx2qm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 386D81C6C96; Sun, 22 May 2022 23:46:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353887AbiETWT4 (ORCPT + 99 others); Fri, 20 May 2022 18:19:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353875AbiETWTs (ORCPT ); Fri, 20 May 2022 18:19:48 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E6BB1A0481 for ; Fri, 20 May 2022 15:19:36 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id j6so8795303pfe.13 for ; Fri, 20 May 2022 15:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FJNM+SC0IIR+V8IbK3b8r/wd9vAA7Bdywff6gYSjtWo=; b=IAMIx2qmVQETKVtS+eBPNuWm9U9fFHmsYSExLr6IDKzceYJaksMhXffQk2IE+D7NiL wmXbzFxZLiUuy9QVTOWQm9RG3+vPowUfkO9qbhQkYe1LFO7/i674voMBdNYzc21ydd9y VbiCumoURfE5ioRSP3xY/gRPs5tCVwCgx8zwwAXczAzxev5vsydhEms8X+dpn2BRvqM/ nB23BMg4wyRlDNWhslbqYT0UF4PPu8Fj2YiPgxdXX+ywqOhhjIYg5msgduqq+0MkKevb 5+t+n+gaaYno1lbeY08X7cOYSAlFJqtvx+aLNBc/LWV208pz0X9JKLYdd+9VtQi02Evx RwAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=FJNM+SC0IIR+V8IbK3b8r/wd9vAA7Bdywff6gYSjtWo=; b=M7jfy5RocrFh9KBnezriy4PsCyaCh8Odd++P79Tf2mLgyggRGSBl+IL3EOjiWKykBt sQitKFORmKBPHBk3DLD6lQYwJsPMzdpUI3ydrdwb/e89LwDA01PyxlSjK4l8zQE9cvDx NXTXEJjbEp9UcceIQB/KlBklzqVYVxPQUxsOoKheugUwbD1EZptOtGhxIpgwmWYiylT9 zUDxsUTuMkQDIb4M0qhcqKITx8TSMIFPHBMcHPEhsVionBtxIsd/e5ooJqirFTFAuSkv btTA81JC2Qr5cKUzhOTs4no6RKoqRkIoJA97mM63i16Nn4ZzSLqDYS3F3mE4it6368cL 0NLg== X-Gm-Message-State: AOAM530zFmnqhhltqMa409A/0bb5D499D2imIbs1HdWHl9Ge3mPvhV6W 8bSNgIukB5V8t4rIleudgCTbiv+XTEQ= X-Received: by 2002:a63:5c22:0:b0:3db:141c:6db2 with SMTP id q34-20020a635c22000000b003db141c6db2mr10186919pgb.198.1653085175156; Fri, 20 May 2022 15:19:35 -0700 (PDT) Received: from google.com ([2620:15c:211:201:828d:ad52:eebc:6659]) by smtp.gmail.com with ESMTPSA id q7-20020a170902edc700b0016168e90f37sm224221plk.152.2022.05.20.15.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 15:19:34 -0700 (PDT) Sender: Minchan Kim Date: Fri, 20 May 2022 15:19:32 -0700 From: Minchan Kim To: Mike Kravetz Cc: John Hubbard , Andrew Morton , syzbot , linux-kernel@vger.kernel.org, linux-mm@kvack.org, llvm@lists.linux.dev, nathan@kernel.org, ndesaulniers@google.com, syzkaller-bugs@googlegroups.com, trix@redhat.com, Matthew Wilcox , Stephen Rothwell , David Hildenbrand Subject: Re: [syzbot] WARNING in follow_hugetlb_page Message-ID: References: <00000000000077377c05dee75f63@google.com> <20220513102617.c464c4f566052838e911a3ec@linux-foundation.org> <75f09063-d184-7d44-17a1-ed04be5eb953@oracle.com> <20220513161910.d1b73583cdb2e33562aa86e5@linux-foundation.org> <4809b134-a37a-50b8-4c25-44548bc1048f@nvidia.com> <6d281052-485c-5e17-4f1c-ef5689831450@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6d281052-485c-5e17-4f1c-ef5689831450@oracle.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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, May 16, 2022 at 08:37:01PM -0700, Mike Kravetz wrote: < snip > > > I need to look at this a little more closely, it is making me wonder > > whether the is_pinnable_page() check is a problem in this path. The > > comment in try_grab_folio() indicates that the early return is a hack > > (it assumes that the caller is in the gup fast path), and maybe the hack > > is just wrong here--I think we're actually on the slow gup path. Not > > good. > > > > Mike, any thoughts here? > > > > Do you know why try_grab_compound_page(now try_grab_folio) checks for > pinnable when try_grab_page does not? > > Then I guess the next question is 'Should we allow pinning of hugetlb pages > in these areas?'. My first thought would be no. But, recall it was 'allowed' > until that commit which changed try_grab_page to try_grab_compound_page. The reason we don't allow longterm pinning in CMA area is to improve big contigus memory allocation sccuess ratio when someone claim the memory space. Thus, any pages mapped at userspace given the CMA area shouldn't be pinned with longterm. Otherwise, the cma_alloc will fail due to migration failure. In hugetlb case(I might miss something..), the CMA memory was already claimed by hugeTLB and the big contiguous memory was mapped at userspace so there is no reason to prevent longterm pinning since HugeTLB will never claim those CMA memory until user release the memory and HugeTLB free the range using cma_release. > In the 'common' case of compaction, we do not attempt to migrate/move hugetlb > pages (last time I looked), so long term pinning should not be an issue. > However, for things like memory offline or alloc_contig_range() we want to The memory offline would be an issue so we shouldn't allow pinning of any pages in *movable zone*. Isn't alloc_contig_range just best effort? Then, it wouldn't be a big problem to allow pinning on those area. The matter is what target range on alloc_contig_range is backed by CMA or movable zone and usecases. IOW, movable zone should be never allowed. But CMA case, if pages are used by normal process memory instead of hugeTLB, we shouldn't allow longterm pinning since someone can claim those memory suddenly. However, we are fine to allow longterm pinning if the CMA memory already claimed and mapped at userspace(hugeTLB case IIUC). Please correct me if I miss something. Thanks.