Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp874645rwi; Thu, 13 Oct 2022 06:25:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66cta3tmfEI7dQTGfMWQVgHZP/i4CXJuFQgocyy28eAnU69NPJmgNkPGRmFYf+LDbctEm2 X-Received: by 2002:a05:6402:847:b0:45c:c716:4b76 with SMTP id b7-20020a056402084700b0045cc7164b76mr5676758edz.113.1665667527075; Thu, 13 Oct 2022 06:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665667527; cv=none; d=google.com; s=arc-20160816; b=UQQe6qn4wT5LJeHGmbKQ8CChtvXgIegcMZvOxJGWiMsa0M8TwMMTl9kGuMEoxq/WMa zPPZrQnyLqcZZGmOsBQsuI3SI0YSyWC/pTau2huAvCVlqeMkINDEdivgwUOEXQ2X+8s0 ZLGEjEdSTNU4Ts+2x/+T9EaHBkfMefZo9hCYAkEnHXC7jkewverkLM5d3nF4NiRdZ17G pPN4EjVJ3g0liGf/CjqZmVQSN8BrQo04nUhwPy0wtycbEcGRmhbIFSuXoMUpmKjHpWUq 20R3UFaJGuPExHPV/5n57xBbxxi6R3rWrDmgesYqPsCKkjFmoN7bs3VjP6WpKandqD09 SJag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pQcd7QYBrfrcu/BD1EO4wF8Gr1oJqdtW3FRbiiR9OCI=; b=b8cZUlFB5NpMvntLJx6lKhBEZn4Ac/HsnNAy99osOFqvEDNYSBbcyF5i/x471QPnSc jyaWkrxWuDYEifhQJjHPLUIuq29MGBiOmn30hQ4X060W9RXjkfSfs+xSTaKhVvcBLMmL SsSzWfnWY4qnzfndRvTG3AmG/b0dWW5GmYiOLZuIGVvBod2Jh2r1sokSlN3OzH7iv9UU Z3nExo5SAPCtJbtH4JDrvu9AY1q5uZcYLdqryYRcxRTgh9eTdtRyGu0cUejARoe1Sc6H abPpT0zCSrOoZ63sorGN0qLhPajPjODpg8hts48rnjnscspiVutac8qWLwvLd5fXjUIM 8X/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=a8zrA3w+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du19-20020a17090772d300b0078d4e67ca81si21677864ejc.605.2022.10.13.06.25.01; Thu, 13 Oct 2022 06:25:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=a8zrA3w+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229930AbiJMNRt (ORCPT + 99 others); Thu, 13 Oct 2022 09:17:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbiJMNRq (ORCPT ); Thu, 13 Oct 2022 09:17:46 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1C1CAC4AD; Thu, 13 Oct 2022 06:17:44 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A2507226AB; Thu, 13 Oct 2022 13:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1665667063; h=from:from:reply-to: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=pQcd7QYBrfrcu/BD1EO4wF8Gr1oJqdtW3FRbiiR9OCI=; b=a8zrA3w+OB8AUhikPpmcrktA7TTbopwkxEHR63dbznsNKrkeiyiGBLxlZmVBO1wwG3sWKy +nY5oD+LL6Ggwu57/D1k0SLfrwVSK76TojCXHaEzoyP1/68hY3w6XYcKArB8zTlF33aOpa 26gcGvM8VH03AkwqrMlL84xxfk8C+MM= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 70C9113AAA; Thu, 13 Oct 2022 13:17:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uN66GfcPSGPeKwAAMHmgww (envelope-from ); Thu, 13 Oct 2022 13:17:43 +0000 Date: Thu, 13 Oct 2022 15:17:42 +0200 From: Michal Hocko To: Zhongkun He 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 Subject: Re: [External] Re: [RFC] mm: add new syscall pidfd_set_mempolicy() Message-ID: References: <20221010094842.4123037-1-hezhongkun.hzk@bytedance.com> <582cf257-bc0d-c96e-e72e-9164cff4fce1@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. -- Michal Hocko SUSE Labs