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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32AADC43217 for ; Thu, 13 Oct 2022 13:42:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229976AbiJMNms (ORCPT ); Thu, 13 Oct 2022 09:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229989AbiJMNmn (ORCPT ); Thu, 13 Oct 2022 09:42:43 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEC02114DE0 for ; Thu, 13 Oct 2022 06:42:37 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id 70so2008107pjo.4 for ; Thu, 13 Oct 2022 06:42:37 -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=NOLoQjm6lEWHmulfqFpQ7MDS9fPvqNaIDPSIxB0GFo8=; b=AvHPQ5/wcBFLkRUYUUmEVMR4gBWtumKwj8eJQTXJ6itkibd81unu/Z4MZdHkHxmlv2 moQQBzzXt4AybwebklULodcvG7oheLdkbNh4CoEDNi0c1l8rb5fxynNbIshI9zHNWQNj KLhmeb+LxE53o8VjCLGoaOvA0ihmkRPh0P1vrfU+pNA9QBOjgFJW4FC+zNUFnm1C8Tld 2thzHhVW1H5No+n518ILMuXmeOv4ETfBFX/i9kpNFCEC5n9xBh7GScNuVKaRAwVU56hc 0UZ1CaCCrjsl3aYFT6Z8Fruo3zs4xovnP1oL93Q0oGyVYjeBZr+wBFFFp9UZrgb6va/G Wudw== 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=NOLoQjm6lEWHmulfqFpQ7MDS9fPvqNaIDPSIxB0GFo8=; b=dsUp8j7c8soT4oBuwTzIRTDWphyXmo+s41mmt+H9VMxfr81I26FAP8zXKkJW20lgaW /abfbJ2aVXurH/dzpvzQRjRFnHfEe/7AAo8NyrDCXtSazYAJlqwnqOPXflBGRPt7LIXN tJqbbpiClmiJ6OHSzlvg3NG+CdwhTLCeKrd5/W5nyJV3W9+uyzW+l2IaTAr6e01UE7SA m+EMms99OBwzJgxuNc+fhlqYPLpcjx2BQ4YJylqrlSNMHNS9avPBpfk84Dxmj7FHWpqq X6v7fQSpNIOw9ks8HaVZhFdFST8vO/v9R12iLxyyUoX11anPqDp+LQTZOtdA58uZjxkt WSMg== X-Gm-Message-State: ACrzQf0VQrjuOIDAbuEXW0e8bh3tCJBBtyWPctDL2TxMaz1L67qDlVce w/u3Nv8j+UMN/5A01D83SzQxKw== X-Google-Smtp-Source: AMsMyM6FkIPSzrfH5vm5egxoGzAlEomfBe9Ic3Qi2U3S4jqkZ9v4n/W5IbztJfqkilvpnPObUtKyvg== X-Received: by 2002:a17:90a:bd91:b0:20d:2add:96a4 with SMTP id z17-20020a17090abd9100b0020d2add96a4mr11384510pjr.195.1665668556405; Thu, 13 Oct 2022 06:42:36 -0700 (PDT) Received: from [10.4.223.70] ([139.177.225.240]) by smtp.gmail.com with ESMTPSA id i66-20020a626d45000000b00562a71d719fsm1974504pfc.155.2022.10.13.06.42.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Oct 2022 06:42:36 -0700 (PDT) Message-ID: Date: Thu, 13 Oct 2022 21:42:30 +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 Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org > On Thu 13-10-22 20:50:48, Zhongkun He wrote: >>>> 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. >>> >>> Wouldn't it make more sense to get rid of a different treatment and >>> treat all memory policies the same way? >> >> I found a case, not sure if it makes sense. If there is no policy >> in task->mempolicy, the use of atomic_{inc,dec} can be skiped >> according to MPOL_F_STATIC. Atomic_{inc,dec} in hot path may reduces >> performance. > > I would start with a simple conversion and do any potential > optimizations on top of that based on actual numbers. Maybe we can > special case default_policy to avoid reference counting a default (no > policy case). A simple check for pol == &default_policy should be > negligible. Got it, thanks for your reply and suggestions.