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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE94ACCA479 for ; Tue, 28 Jun 2022 22:33:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D18D6B0071; Tue, 28 Jun 2022 18:33:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 281B88E0002; Tue, 28 Jun 2022 18:33:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 149988E0001; Tue, 28 Jun 2022 18:33:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 06E4C6B0071 for ; Tue, 28 Jun 2022 18:33:57 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D677337F20 for ; Tue, 28 Jun 2022 22:33:56 +0000 (UTC) X-FDA: 79629098472.03.7C37433 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 3E40814002E for ; Tue, 28 Jun 2022 22:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656455635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bYK15YVdxP+HlFRILW4dcrjcjvcQxAk2DAaS0YwPQaE=; b=VnSlT20+luMi0uWAHiH3iqWjmbeUjxVjmeN4BCcfGssokRJpNrqZS2zyUFjogSO2XwBCfk 4RzpGExLoVH2/mpphLOSMj2KUbg+Faa860jXIlJFTtqyd3A06815ZXmLZqWEsVQWzTKo9w xzQKXTTPEh/HrrDOoG4XwmsQOSnGzlg= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-ys8EwE1rOMm9zADYgOAvGw-1; Tue, 28 Jun 2022 18:33:54 -0400 X-MC-Unique: ys8EwE1rOMm9zADYgOAvGw-1 Received: by mail-io1-f70.google.com with SMTP id c8-20020a056602334800b0067500ca88aaso7432476ioz.0 for ; Tue, 28 Jun 2022 15:33:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bYK15YVdxP+HlFRILW4dcrjcjvcQxAk2DAaS0YwPQaE=; b=N65M2XD9g8YPusj8SNPpyhFk8NR8E5t/pPxqT4iSPPS7nsdxxoKGEgY6Rsd8QrlrDG BnXPfXbW47jcKj7IxTTDV4T0E+lqOGW44v33+wUUEo1Rn9lx8orw/gMCClHzkvoJpASP ZeQqNl+ivi1Y0SCfRipo+C5cYoNeGeqoRzqRncn8IRGo8/fTEpHkuNVfxSBkuF5WJG9Q CqoCdZXmBSCdhLNDT61p3rjyqc8/DXP+B5VpHFqDatGbpBj/bbad7Du6nZW0trZYHvig pxIscK00aBppYhs6yG+XQvJnet9TLcmc8bqoJ9maxQd2QO1riq3rdWeI3yuj2UVr0qym UGJw== X-Gm-Message-State: AJIora9ZmM757ts8xtuNV8vO08JcqV4XsoyiLLKSSMEQByHkfJpZxWDv ulxu9MZLxJU5EQ9p4DAcrAT4/ST47Nt9dmJNgFIfBEqSeBXx31n+/66268tH0dWH/q14nBV6ZDm XR77fT+jXqyM= X-Received: by 2002:a02:a597:0:b0:339:e1ef:7de with SMTP id b23-20020a02a597000000b00339e1ef07demr215938jam.291.1656455633593; Tue, 28 Jun 2022 15:33:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tET+xoMBUzSfJNWaC0HczRlJeNGe/NWsP2TTp3pBKcwrNn51HeSZf5ws2xFlV8EW/B6YVdDg== X-Received: by 2002:a02:a597:0:b0:339:e1ef:7de with SMTP id b23-20020a02a597000000b00339e1ef07demr215919jam.291.1656455633362; Tue, 28 Jun 2022 15:33:53 -0700 (PDT) Received: from xz-m1.local (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id f10-20020a056638112a00b00339c55c1c43sm6565378jar.133.2022.06.28.15.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 15:33:52 -0700 (PDT) Date: Tue, 28 Jun 2022 18:33:50 -0400 From: Peter Xu To: John Hubbard Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Andrew Morton , David Hildenbrand , "Dr . David Alan Gilbert" , Andrea Arcangeli , Linux MM Mailing List , Sean Christopherson Subject: Re: [PATCH 1/4] mm/gup: Add FOLL_INTERRUPTIBLE Message-ID: References: <20220622213656.81546-1-peterx@redhat.com> <20220622213656.81546-2-peterx@redhat.com> <16c181d3-09ef-ace4-c910-0a13fc245e48@nvidia.com> MIME-Version: 1.0 In-Reply-To: <16c181d3-09ef-ace4-c910-0a13fc245e48@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VnSlT20+; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf23.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656455636; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bYK15YVdxP+HlFRILW4dcrjcjvcQxAk2DAaS0YwPQaE=; b=pq9DKcH6lJDj73Vn39hZjKAMNdiAVcUjh/dZPHqeQ+n6BOejJY8hKHMFoNXt+0YWVqDv6z ieC6Oan1AEEJih+uCH4uoNmntRYkZbnhKnsyK+PKY5+vSBQLzHdK7fU3LqaJcszn2autQ9 7FIs9PuBG9BXRDHnWE5IMIipr+DFVGw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656455636; a=rsa-sha256; cv=none; b=WOx4BOqSE4VkKkEffYGq2VMJLvdiO2XTCF6/Iaa+O4mwW+7rO8OtAihUX9oTnT8vNDXyvY 77HNfpvkr6vV/Bii71CGQSdGlwvCEXR3O7wzXZD368iESdghXeH1F4tz2HtIhjN2MCz218 Zx4epsL05eOIm0Ca9/2ekCdDeX2s4Zw= X-Stat-Signature: 69qig8f3syc9fr43mg3ukx6o1ijf1cp5 X-Rspamd-Queue-Id: 3E40814002E X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VnSlT20+; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf23.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam12 X-HE-Tag: 1656455636-104066 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 Tue, Jun 28, 2022 at 02:40:53PM -0700, John Hubbard wrote: > On 6/28/22 12:31, Peter Xu wrote: > > > > diff --git a/mm/gup.c b/mm/gup.c > > > > index 551264407624..ad74b137d363 100644 > > > > --- a/mm/gup.c > > > > +++ b/mm/gup.c > > > > @@ -933,8 +933,17 @@ static int faultin_page(struct vm_area_struct *vma, > > > > fault_flags |= FAULT_FLAG_WRITE; > > > > if (*flags & FOLL_REMOTE) > > > > fault_flags |= FAULT_FLAG_REMOTE; > > > > - if (locked) > > > > + if (locked) { > > > > fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; > > > > + /* > > > > + * We should only grant FAULT_FLAG_INTERRUPTIBLE when we're > > > > + * (at least) killable. It also mostly means we're not > > > > + * with NOWAIT. Otherwise ignore FOLL_INTERRUPTIBLE since > > > > + * it won't make a lot of sense to be used alone. > > > > + */ > > > > > > This comment seems a little confusing due to its location. We've just > > > checked "locked", but the comment is talking about other constraints. > > > > > > Not sure what to suggest. Maybe move it somewhere else? > > > > I put it here to be after FAULT_FLAG_KILLABLE we just set. > > > > Only if we have "locked" will we set FAULT_FLAG_KILLABLE. That's also the > > key we grant "killable" attribute to this GUP. So I thought it'll be good > > to put here because I want to have FOLL_INTERRUPTIBLE dependent on "locked" > > being set. > > > > The key point is the connection between "locked" and killable. If the comment > explained why "locked" means "killable", that would help clear this up. The > NOWAIT sentence is also confusing to me, and adding "mostly NOWAIT" does not > clear it up either... :) Sorry to have a comment that makes it feels confusing. I tried to explicitly put the comment to be after setting FAULT_FLAG_KILLABLE but obviously I didn't do my job well.. Maybe that NOWAIT thing adds more complexity but not even necessary. Would below one more acceptable? /* * We'll only be able to respond to signals when "locked != * NULL". When with it, we'll always respond to SIGKILL * (as implied by FAULT_FLAG_KILLABLE above), and we'll * respond to non-fatal signals only if the GUP user has * specified FOLL_INTERRUPTIBLE. */ Thanks, -- Peter Xu