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 750ECC4332F for ; Wed, 12 Oct 2022 11:22:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A2266B0071; Wed, 12 Oct 2022 07:22:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 851226B0073; Wed, 12 Oct 2022 07:22:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CABA900002; Wed, 12 Oct 2022 07:22:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5AE2D6B0071 for ; Wed, 12 Oct 2022 07:22:30 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 247C712120A for ; Wed, 12 Oct 2022 11:22:30 +0000 (UTC) X-FDA: 80012059260.19.FC4823E Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf04.hostedemail.com (Postfix) with ESMTP id A82BA4001C for ; Wed, 12 Oct 2022 11:22:28 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id d7-20020a17090a2a4700b0020d268b1f02so1710057pjg.1 for ; Wed, 12 Oct 2022 04:22:28 -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=nky5UA9/w8YUBIpkVBR5e9cekqkEeekQYjUhuGyBtKg=; b=F+FQNnDoQHD5t5tPpMk0+FKE7G6dvQAGJzFK5fVeXzDJFPyaI1PVeIoRWVFByjqRcQ F/WBP355WLp+tg2jIQTGyypaHGkIAkY7IqZFqe5Hl9NQQJcD3YFOK1/NhXJrNuvd3zyk V/Sob77RzIKbhO/njyZXVvSrlzLMBYDPl1mH8HhQ3dDiKCQqSG1uRGEhfI6+cd98e7Fc 7p34h/hQP0Mcy36K70/zxOSM4qIYCEKbOiX1E/j3bKS5ozsdEz2K5wOuEq1IKFASq8Om 0zC9FhuF6f13xKFTE+CROJ6J7upO9d3YCxVKYGJ2QwYVdtfGuAiiG4d46ZT4OJjBqnJT 8saQ== 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=nky5UA9/w8YUBIpkVBR5e9cekqkEeekQYjUhuGyBtKg=; b=ccAqOXHVbslAqbmegz4Sj7ba8KrtJMptRS6fUo3C6kuLTDOqnnG8As+EpmyYCq5pd1 Va7X2dfgwdCTvXB+iB43/MnjHRkUMke/9OCtV3uvUO3KRb+3qnzQG4zFwwRt93/SrFHV xZDZqslqKrJWxcizKMP8oSEYqWxiDUQLs9XKobKm+WUNkudkF6qluCKlW5zvZiL+6ELR rTLjoMt/Utz5nY+O/ZsnVIJfWPYTkjTuAFhI1hNRFwXKfp4rkOLk+YWULD7e82QZ6bkK ZZQ69KvhgpWj3U2/sJ/9bmuxApp/ZmGrprDRVNh68Q3FafRG+C8boYhUR8DIaCguP/9P sO8Q== X-Gm-Message-State: ACrzQf2Og67bMpKU/AOonyb/OW5ukcmbEILU95zjcIWyC/Wz+Q+aeH1/ wGimmTa8ai/NzlAiZq6D58f5JQ== X-Google-Smtp-Source: AMsMyM5VAuc3jwLsVUUvKgOJss7juuz6l0hUGBBMAC7PbDxQU9lzEbHe4f+9/QYUQXvashRZDobT4A== X-Received: by 2002:a17:90b:38c8:b0:20d:9ac4:b476 with SMTP id nn8-20020a17090b38c800b0020d9ac4b476mr170513pjb.26.1665573747385; Wed, 12 Oct 2022 04:22:27 -0700 (PDT) Received: from [10.68.76.92] ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id q194-20020a632acb000000b00439d071c110sm9422302pgq.43.2022.10.12.04.22.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Oct 2022 04:22:26 -0700 (PDT) Message-ID: Date: Wed, 12 Oct 2022 19:22:21 +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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665573749; 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=nky5UA9/w8YUBIpkVBR5e9cekqkEeekQYjUhuGyBtKg=; b=0s+wQzLtEdXqvpi+K4UgSkEXab410GgPrljTr8kLElv1vWBafszvexEVOqXrj0rs34x6Cn 7bWcq+aY9bNVjcAqiJFrfykDBOqHyNk4VIy6SknNaJG4hNEokVSkBLJ9YcwWg/J7+B61Fy uq1XwbSRC0WQfMgjT1jBX8mGiVh4L58= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=F+FQNnDo; spf=pass (imf04.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.216.42 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=1665573749; a=rsa-sha256; cv=none; b=SbEd1wVq6gSmrzdHJ5og4NJAmhRHlKInsSS+UFlSllU5VQJ4iAfngGN3JSMmXhnHgk9yKY OmIhMF5oj7YqMc61DMGQmVnrcVXK1NMVD/XrYgZIddlQQ9RU+LNN0ycHbPtwgKrw8I/t5l rtdWLR8LOQlnYhSK4DEWWEDKI/+sFcU= X-Rspam-User: X-Rspamd-Queue-Id: A82BA4001C X-Stat-Signature: djciu8e7gbneii4bozc1e6kxprcw1wzz Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=F+FQNnDo; spf=pass (imf04.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Server: rspam10 X-HE-Tag: 1665573748-783188 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: > > 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? With the addition of lock add/dec on the hot path, the performance may be degraded. I'll try it to see its performance impact in detail. Thanks.