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=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 1A0B9C433E0 for ; Fri, 19 Jun 2020 11:43:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D77B820CC7 for ; Fri, 19 Jun 2020 11:43:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D77B820CC7 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 4296F8D0095; Fri, 19 Jun 2020 07:43:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D9E18D0089; Fri, 19 Jun 2020 07:43:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EF1C8D0095; Fri, 19 Jun 2020 07:43:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 148058D0089 for ; Fri, 19 Jun 2020 07:43:18 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7B8052DFC for ; Fri, 19 Jun 2020 11:43:17 +0000 (UTC) X-FDA: 76945775634.27.tin20_4608f5726e18 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 4AE3FB7647 for ; Fri, 19 Jun 2020 11:43:17 +0000 (UTC) X-HE-Tag: tin20_4608f5726e18 X-Filterd-Recvd-Size: 3171 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Fri, 19 Jun 2020 11:43:16 +0000 (UTC) Received: by mail-ed1-f42.google.com with SMTP id x25so7337162edr.8 for ; Fri, 19 Jun 2020 04:43:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hmI1oPtC3rQWEmZrp3aXAtd46P9QLxun7OFK/M3s5OA=; b=Mj+aq3oUdX+ZdGPrklULZnrhbxwBeYG8YqI+1kLFhoaMVTVX/glIqqK6cHHCEcvcqQ wBqYwCzAXYjUBc07HVAYH/y364d+6malDB2Vkr4+j5OJaKXk0u9KX4epOQKO8t3Jfop6 w4lU4tON4cMrCyUITAUGt1URjXHZwzmV2j/qDt4gLz66qNzJkrxH5uiBeOniW9JlQ72x LQC4YJ/1yGgQDqR1tAH2qRlbp5/Vhbe6E6s4ze1e0di/aj/DV/8xrVlTc1C0GO7H2ttT sjrVX8czT+9MIQ8avFB7sHG7LRPvqExgzIBA6LQYpwPfavLGr1nliNwhI+CLgi5fb/Zp erfQ== X-Gm-Message-State: AOAM5309AYkPN+ebHgD1HN8ah/TeTJkx7NYKji5cebCMi1HNMe2xczql 3fIPu8IWpCxOvWr6DGPspyX7XLI/ X-Google-Smtp-Source: ABdhPJxOCaF3I54sJ1RYoKer2h+3p+fcaKF0996SvufxwTWMqBpuju72G4jm3jh9qocAt9Myeb2hDA== X-Received: by 2002:a05:6402:17af:: with SMTP id j15mr2777724edy.67.1592566995836; Fri, 19 Jun 2020 04:43:15 -0700 (PDT) Received: from localhost (ip-37-188-189-34.eurotel.cz. [37.188.189.34]) by smtp.gmail.com with ESMTPSA id a62sm4656146ede.45.2020.06.19.04.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 04:43:14 -0700 (PDT) Date: Fri, 19 Jun 2020 13:43:13 +0200 From: Michal Hocko To: Jens Axboe Cc: linux-mm Subject: Re: schedule/sleep over mmget() Message-ID: <20200619114313.GC12177@dhcp22.suse.cz> References: <398032e7-7cbf-3a28-75a7-f6586465f0c6@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <398032e7-7cbf-3a28-75a7-f6586465f0c6@kernel.dk> X-Rspamd-Queue-Id: 4AE3FB7647 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Thu 18-06-20 09:20:40, Jens Axboe wrote: > Hi, > > Got a question that I couldn't immediately find an answer to. io_uring > currently jumps through a few hoops to avoid holding a process mm over > schedule, and it doesn't look like that's necessary. > > Is it fine for a kthread to do mmget/kthread_use_mm at the start, and > only put/unuse when it exits? Or is it more prudent to drop/re-acquire > over schedule for potential longer periods of idleness? Pinning the address space for a long time is not really ideal. This would prevent quite a lot of memory to be released when the primary owner of the address space goes away (willingly or by the OOM killer). Our documentation says * Never use this function to pin this address space for an * unbounded/indefinite amount of time. If you know the kthread is not going to use the mm for some time just pin the mm struct itsef by mmgrab() and then mmget_not_zero() to get the address space for your use again. -- Michal Hocko SUSE Labs