From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFE743A8736 for ; Thu, 18 Jun 2026 07:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781767276; cv=none; b=LwcTYfRJZ1Me6Nxff1PU5hANHxWU9AkzuyYQ+F0oU0G4Qg2K8ExdelY5jNe/eT86TkUGwRBNrPrhoJHGdDd+K7ghajcr0F9EbesOYOs8LVX/bjR5a6rTnN6wdmsGhvLpGLRxRpG6ClZuqQhXfi8rN9omTo7gu8noRnfGQs3nqjA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781767276; c=relaxed/simple; bh=2mSQzrAKSfiWvyojE1htuTgE0b7hjDsD/gjjLoa7UnM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=GiLtwbF5PQCP8qOCC3xVXV39Onjaf/SO8zli23AaGVdpriEAuoazVmaDKgDpbZ5P6A2S8rtxrD+n3g+FPs2qNst0YE5HzFtRn3H+tzv2TNIwe+gJPDxQam2D5k/uJCJvcGMXkUtP4sr3K1vJi1Oj1B+a4C9qmywyRdrLOodyhXQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=HySLrnYz; arc=none smtp.client-ip=91.218.175.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="HySLrnYz" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1781767271; h=from:from: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; bh=GtlEMfVTH63Oa0whvIFuEXdWiCj3k8WGdr0XfDgRc4E=; b=HySLrnYzumRMbNCiHXgZaMm3OwZfCXXP0goIvaNtrjiv774vw6wDkQWW4+fesHYnDoI4lj I23WYJcgTdhtL6qSuIc+TOeVWXkAFWSqfXmy7rU34K5BnOaH11fqhnHsSNee2+AHljjXev B+iBecDkfQDra1ji3AzrFspfDEiOl2A= From: Lance Yang To: zhen.ni@easystack.cn Cc: akpm@linux-foundation.org, vbabka@kernel.org, surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Lance Yang Subject: Re: [PATCH v10 3/4] tools/mm: add page_owner_filter userspace tool Date: Thu, 18 Jun 2026 15:21:03 +0800 Message-Id: <20260618072103.92397-1-lance.yang@linux.dev> In-Reply-To: <20260618035750.3724613-4-zhen.ni@easystack.cn> References: <20260618035750.3724613-4-zhen.ni@easystack.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On Thu, Jun 18, 2026 at 11:57:49AM +0800, Zhen Ni wrote: [...] >+ /* Read and display filtered output */ >+ ret = 0; >+ while ((ret = read(fd, buf, sizeof(buf))) > 0) { >+ size_t written = fwrite(buf, 1, ret, output); >+ >+ if (written != (size_t)ret) { >+ if (errno == EPIPE) { Hmm ... does this work without handling SIGPIPE first? With something like: $ ./page_owner_filter -m handle | head The writer can be killed by SIGPIPE before fwrite() returns EPIPE no? so this branch would usually not be reached ... >+ /* Pipe closed, treat as success */ >+ ret = 0; >+ goto out; >+ } >+ perror("write output"); >+ ret = -1; >+ goto out; >+ } >+ } >+ >+ if (ret < 0) { >+ perror("read page_owner"); >+ goto out; >+ } >+ >+ if (fflush(output)) { fflush() can also be where the broken pipe is reported, but still treats EPIPE as an error ... Shouldn't we ignore/handle SIGPIPE and treat EPIPE from both fwrite() and fflush() as succes? Cheers, Lance >+ perror("flush output"); >+ ret = -1; >+ } >+ >+out: >+ close(fd); >+ if (output != stdout) >+ fclose(output); >+ return ret < 0 ? 1 : 0; >+} >-- >2.20.1 > >