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 B8A0EC4332F for ; Thu, 13 Oct 2022 13:17:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 305346B0071; Thu, 13 Oct 2022 09:17:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B2718E0001; Thu, 13 Oct 2022 09:17:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1531B6B0074; Thu, 13 Oct 2022 09:17:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 00BF66B0071 for ; Thu, 13 Oct 2022 09:17:45 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B88C281432 for ; Thu, 13 Oct 2022 13:17:45 +0000 (UTC) X-FDA: 80015978490.24.E8A4534 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf17.hostedemail.com (Postfix) with ESMTP id 214C84002F for ; Thu, 13 Oct 2022 13:17:44 +0000 (UTC) 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: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665667065; a=rsa-sha256; cv=none; b=Z53PJyVx8VHqGBvCDzEiDyAV2hTlBL0ttUt3OCVTWMvSD5Ugwi3LC/X3uQy0M072GsKUHO VLkSFxFYXaN/FBj1szLo/CO/bkA6lBOIUTc9TCpVk3s0ZoCmU1qwjUtyzlf8yT47Ey96fM I5541f9Qxpl72cegjN7pzZK2IH4sdbM= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=a8zrA3w+; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf17.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665667065; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pQcd7QYBrfrcu/BD1EO4wF8Gr1oJqdtW3FRbiiR9OCI=; b=OJUY9Lj9LXUOkTB5RkhDzEbj04x5tKwV+kmAHQg8d42hTCaRFRxnOu6E93Qto3BRiz54FK zT9TI1n8CofR81QPUjDt4a/8+mzqdi8VeW6vmfu07gQ98fIF8aY/Un7HbtsrqbEd+YtUm1 WGzjcVlgKlepO0d5htFW2mordShPC4k= X-Stat-Signature: iwrnsa3ztjz1cxnfwaem6krrk6u7bxo3 X-Rspamd-Queue-Id: 214C84002F Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=a8zrA3w+; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf17.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1665667064-616518 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 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