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 3D57EC4332F for ; Thu, 13 Oct 2022 10:45:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 637F36B0071; Thu, 13 Oct 2022 06:45:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E7A36B0073; Thu, 13 Oct 2022 06:45:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B10E8E0001; Thu, 13 Oct 2022 06:45:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3AEBE6B0071 for ; Thu, 13 Oct 2022 06:45:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 01D331A07E7 for ; Thu, 13 Oct 2022 10:45:04 +0000 (UTC) X-FDA: 80015593728.26.DBEB27E Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf27.hostedemail.com (Postfix) with ESMTP id D73214002A for ; Thu, 13 Oct 2022 10:45:03 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id 129so1222985pgc.5 for ; Thu, 13 Oct 2022 03:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=zY1ojGxBpTi2hn+yoQwCvHy/W57pGU8ECyExV1y6qnQ=; b=1DWlgqusN67Nh/Lk0vXcd5QO3A5QObZkpdbC+9nCPpKZvveDt4EyVeNBhRLQ23AlXd 977ei/TEQ5w04x8QFrh9vK85nWyFHYCPiEaolBsaz7GeG7QFBSaY+dlNOHno6oOf32ts 4N1sMJ5aaflczzA2acYDlJXdK3LkQbBYEiT9SORWT0jpyBLLwva+RLXppJFiA7cwOt1D xF/2Da+GoVl5CgdIHolQooeSsPun+ic5B1zrsYTlZLUun6fZZ6e/8p258fvfSQXeo8Fi xapBep1B08oRiNU2KOTkkNovTrOeQUwNX8jUj6gAAp91QgWBOTQoKESwmKTfpuiawofo inGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=zY1ojGxBpTi2hn+yoQwCvHy/W57pGU8ECyExV1y6qnQ=; b=8OmYZz9ZEtpcldoztvj5AnDvKOlBb6Z5NYYXGTSpDzMpNDPBCMHV5Y3SgTZJ1i380G qYgZ6g8srnjF/K45263kuOI+9qO3TxOZFZTSwUtYe4SBKf2updib9SXfPSbXb9nkuqhb IdI7h55Uy5LjCu7X8CRnB6QJ5lr7thJ90O9H0jcRRLbmUTFjuIlIxnt0UrQ5bH24fBQP TcD2XsvYtO9Ye2DxiNzHWF4c0+nUFAyRmWAn0p9TLjKSvnAHF6IMmz5MFK+qPP8yECGp 6ZAu19Z4fMNdTgTNVqwP7UhJm6K50HR6CGHYeEeCrP0obMdQC+5VeCcg31jU7TTGIoGG ic4g== X-Gm-Message-State: ACrzQf3k+SNHCTF5l3Qjvce4HIgJTfhI0o7ve3gkvAZSML9E1eYmW43/ H/34Dp4Jif6NdKZECaCgCrKiKg== X-Google-Smtp-Source: AMsMyM7MHYTMMEe0zkVoDtJLCO79Qh90HiVUU8OihvpobkC1CmBNEd2x4c1OtpT0T5YAID0rfu4/zw== X-Received: by 2002:a05:6a00:23d2:b0:565:84d7:64c3 with SMTP id g18-20020a056a0023d200b0056584d764c3mr11206898pfc.20.1665657902431; Thu, 13 Oct 2022 03:45:02 -0700 (PDT) Received: from [10.68.76.92] ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id r1-20020aa79ec1000000b00538056de6ecsm1687688pfq.52.2022.10.13.03.44.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Oct 2022 03:45:01 -0700 (PDT) Message-ID: Date: Thu, 13 Oct 2022 18:44:55 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: [External] Re: [RFC] mm: add new syscall pidfd_set_mempolicy() To: Michal Hocko Cc: corbet@lwn.net, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, wuyun.abel@bytedance.com References: <20221010094842.4123037-1-hezhongkun.hzk@bytedance.com> <582cf257-bc0d-c96e-e72e-9164cff4fce1@bytedance.com> From: Zhongkun He In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=1DWlgqus; spf=pass (imf27.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665657904; a=rsa-sha256; cv=none; b=RZRE4EfCZhUlv2XbsSe/XlPwAyzHIGsaYlpqoqnPj9wuQ5PjVm2Vb+Y+ANnQInF4210KSy HhJUbLocAzVh1ZWwmWhy/6k/cvpYowOM5v/Z7YfqHuvDO3cCPMue1xVLf0s8og/DFZZMad mCljWWjftDYClVIgqs0Sw6FhLXf/0vI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665657904; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zY1ojGxBpTi2hn+yoQwCvHy/W57pGU8ECyExV1y6qnQ=; b=A8dI89PBHlTxa9BqxDOH7zJXgwsHyzupwb97M0nW7ejrwXiCRM/d16q/603kPTUTTIicLA edUjp/u1UdxBMvbjKrdp7sS6lVZjBAfc8kQZmHm+TJZmH8J524FP7yBnoAnTy9B75zVt94 22uHIvSVXAS4ouR1cf/qoFI+uFb6s6w= X-Rspamd-Server: rspam05 X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=1DWlgqus; spf=pass (imf27.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Stat-Signature: ocrp4w93chm78jhj3io3wn8z9ckf3jff X-Rspamd-Queue-Id: D73214002A X-HE-Tag: 1665657903-127170 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 Wed 12-10-22 19:22:21, Zhongkun He wrote: >>> >>> Yes, this will require some refactoring and one potential way is to make >>> mpol ref counting unconditional. The conditional ref. counting has >>> already caused issues in the past and the code is rather hard to follow >>> anyway. I am not really sure this optimization is worth it. >>> >>> Another option would be to block the pidfd side of things on completion >>> which would wake it up from the task_work context but I would rather >>> explore the ref counting approach first and only if this is proven to be >>> too expensive to go with hacks like this. >> >> Hi Michal >> >> The counting approach means executing mpol_get/put() when start/finish using >> mempolicy,right? > > We already do that via mpol_{get,put} but there are cases where the > reference counting is ignored because it cannot be freed and also mpol_cond_put > resp. open coded versions of mpol_needs_cond_ref. Hi Michal Could we try to change the MPOL_F_SHARED flag to MPOL_F_STATIC to mark static mempolicy which cannot be freed, and mpol_needs_cond_ref can use MPOL_F_STATIC to avoid freeing the static mempolicy. MPOL_F_SHARED loses its original meaning in counting approach. Thanks.