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=-0.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 A9C7BC54E7E for ; Sat, 9 May 2020 23:14:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 37C78208DB for ; Sat, 9 May 2020 23:14:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TfPHhOQw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37C78208DB 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 74D1D900010; Sat, 9 May 2020 19:14:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D50C8E0003; Sat, 9 May 2020 19:14:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59D81900010; Sat, 9 May 2020 19:14:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 3DADD8E0003 for ; Sat, 9 May 2020 19:14:47 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id F408A3A97 for ; Sat, 9 May 2020 23:14:46 +0000 (UTC) X-FDA: 76798737372.16.bike53_c9684cf1a80b X-HE-Tag: bike53_c9684cf1a80b X-Filterd-Recvd-Size: 8178 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Sat, 9 May 2020 23:14:46 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id x2so2871697pfx.7 for ; Sat, 09 May 2020 16:14:46 -0700 (PDT) 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=cFQEFHamvJeO++DzgevGO5UBaz8G9NUtSfCTpvC4iWo=; b=TfPHhOQwhqJHJ82A0wmjrQI3vCRANxfMZSw27kVD6T7S9YqwwoY7Ygagq51RWRZQCV tYOBqqpiFUUR7yqREoGDDtKNNqNPmbIGHz6Qaj+fkmOIkXK11f4K3INZpCMTT9asQwoJ 7+ZmbUQLzPDXMTMwt2/neXXg+dCB8qZOpn64t8+RX06orDMgwRFGH8ssp1tevtP6uvtd qPqpiu9WtFajUd49dZwa3O8BjqKHPiFkL+nSwdAFCQYJx6uJN1pnh+chAR+IJ1aL/YHq ExmEvqOum+zfgln2hShEx0QqVYBiJrF87HK/Hd+3pxKxKVz/lvTm6X7O60x2QVgPNcNJ h1kg== 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=cFQEFHamvJeO++DzgevGO5UBaz8G9NUtSfCTpvC4iWo=; b=XHjCISnwiycAmRMXWifpLU8+xF61miDAwA7FMagsOPVKWaodjcu0QuPYirOiIIsNWg VSDPLx2VjpDokKtqLvNdyOgojJsAl7hc8qDNIeLvNxMVU5O6YBKuJaxBE9+mZoEJC/YM h5cqzWyZEGsvD4NcLgdTih147Y5kUsmVTko3sNXNylUdTd1vXWXeZjJV7fM6xKwv55Hb ifRJFRgLkjkdigUrncKg/sQDevVuElWDTXe+TZUY6gBoZq8cXOt3f7/YzaOeMnJGL14i 1SuQwBscgDWRzOVpZbMifwL2UEOv7VKyiKNHqIOTR+wk7W7RzsiupV4NPEeLKffyiX8v Rbgw== X-Gm-Message-State: AGi0PuYD76CLz/po8MvxXYZu61hoEaqy0MASzsjTEkvSTi8rMwbVBDY7 rP54c82y1dC47A+iuFrjaFg= X-Google-Smtp-Source: APiQypLEtinKLOseJYS5AqPEVFV8rGU5ABR8NbhK6TXdEM4VBfW4ckpSgPbnOH2o6nFwMb3Yo8Pxbg== X-Received: by 2002:a63:3c4c:: with SMTP id i12mr8099212pgn.448.1589066085023; Sat, 09 May 2020 16:14:45 -0700 (PDT) Received: from google.com ([2620:15c:211:1:3e01:2939:5992:52da]) by smtp.gmail.com with ESMTPSA id z1sm5732684pjn.43.2020.05.09.16.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 May 2020 16:14:43 -0700 (PDT) Date: Sat, 9 May 2020 16:14:41 -0700 From: Minchan Kim To: Christian Brauner Cc: Andrew Morton , Vlastimil Babka , LKML , linux-mm , linux-api@vger.kernel.org, oleksandr@redhat.com, Suren Baghdasaryan , Tim Murray , Daniel Colascione , Sandeep Patil , Sonny Rao , Brian Geffon , Michal Hocko , Johannes Weiner , Shakeel Butt , John Dias , Joel Fernandes , Jann Horn , alexander.h.duyck@linux.intel.com, sj38.park@gmail.com, Christian Brauner , Kirill Tkhai Subject: Re: [PATCH v7 5/7] mm: support both pid and pidfd for process_madvise Message-ID: <20200509231441.GC61301@google.com> References: <20200302193630.68771-1-minchan@kernel.org> <20200302193630.68771-6-minchan@kernel.org> <14089609-5fb1-b082-716f-c2e129d27c48@suse.cz> <20200311004251.GB87930@google.com> <20200508183653.GB125527@google.com> <20200508160415.65ff359a9e312c613336587b@linux-foundation.org> <20200509124817.xmrvsrq3mla6b76k@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200509124817.xmrvsrq3mla6b76k@wittgenstein> 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: Hi Christian, On Sat, May 09, 2020 at 02:48:17PM +0200, Christian Brauner wrote: > On Fri, May 08, 2020 at 04:04:15PM -0700, Andrew Morton wrote: > > On Fri, 8 May 2020 11:36:53 -0700 Minchan Kim wrote: > > > > > > > > ... > > > > > > Per Vlastimil's request, I changed "which and advise" with "idtype and > > > advice" in function prototype of description. > > > Could you replace the part in the description? Code is never changed. > > > > > > > Done, but... > > > > > > > > ... > > > > > > There is a demand[1] to support pid as well pidfd for process_madvise to > > > reduce unnecessary syscall to get pidfd if the user has control of the > > > target process(ie, they could guarantee the process is not gone or pid is > > > not reused). > > > > > > This patch aims for supporting both options like waitid(2). So, the > > > syscall is currently, > > > > > > int process_madvise(idtype_t idtype, id_t id, void *addr, > > > size_t length, int advice, unsigned long flags); > > > > > > @which is actually idtype_t for userspace libray and currently, it > > > supports P_PID and P_PIDFD. > > > > What does "@which is actually idtype_t for userspace libray" mean? Can > > you clarify and expand? > > If I may clarify, the only case where we've supported both pidfd and pid > in the same system call is waitid() to avoid adding a dedicated system > call for waiting and because waitid() already had this (imho insane) > argument type switching. The idtype_t thing comes from waitid() and is > located int sys/wait.h and is defined as > > "The type idtype_t is defined as an enumeration type whose possible > values include at least the following: > > P_ALL > P_PID > P_PGID > " > > int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options); > If idtype is P_PID, waitid() shall wait for the child with a process ID equal to (pid_t)id. > If idtype is P_PGID, waitid() shall wait for any child with a process group ID equal to (pid_t)id. > If idtype is P_ALL, waitid() shall wait for any children and id is ignored. > > I'm personally not a fan of this idtype_t thing and think this should > just have been > > > int pidfd_madvise(int pidfd, void *addr, > > > size_t length, int advice, unsigned long flags); > and call it a day. That was the argument at that time, Daniel and I didn't want to have pid along with pidfd even though Kirill strongly wanted to have it. However you said " Overall, I don't particularly care how or if you integrate pidfd here." at that time. https://lore.kernel.org/linux-mm/20200113104256.5ujbplyec2sk4onn@wittgenstein/ I asked a question to Kirll at that time. " > Sounds like that you want to support both options for every upcoming API > which deals with pid. I'm not sure how it's critical for process_madvise > API this case. In general, we sacrifice some performance for the nicer one > and later, once it's reported as hurdle for some workload, we could fix it > via introducing new flag. What I don't like at this moment is to make > syscall complicated with potential scenarios without real workload. Yes, I suggest allowing both options for every new process api " https://lore.kernel.org/linux-mm/9d849087-3359-c4ab-fbec-859e8186c509@virtuozzo.com/ You didn't give the opinion at that time, either(I expected you will make some voice then). What I could do to proceed work was separate it as different patch like this one to get more attention in future. And now it works. Let me clarify my side: I still don't like to introduce pid for new API since we have pidfd. Since you just brought this issue again, I want to hear *opinions* from others, again. > > Also, if I may ask, why is the flag argument "unsigned long"? > That's pretty unorthodox. The expectation is that flag arguments are > not word-size dependent and should usually use "unsigned int". All new > system calls follow this pattern too. Nothing special in this flag: Let me change it as "unsigned int". I will send the change once we have an agreement on "pidfd" argument. Thanks for the review, Christian!